docker+k8s

kubectl version
node server.js
1. Create a file Dockerfile command in the project directory
FROM node:8.11.2
WORKDIR app
COPY . .
EXPOSE 8081
ENTRYPOINT [ "node","server.js" ]

2.docker build -t yinwensheng / kube-node-demo:. V1 strokes wrapped 镜像 
docker build -f /path/to/a/Dockerfile .

3.docker login --username yinwensheng 登录 do
 
4.docker push yinwensheng / kube-node-demo: v1 above 传镜 image
 
5.yaml deployment to deploy the application to k8s
Create a file called deployment.yaml of yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kube-node
spec:
replicas: 2
template:
metadata:
labels:
app: web
spec:
containers:
- name: kube-node-demo-instance
image: yinwensheng/kube-node-demo1:v1
ports:
- containerPort: 8081

 

6. Do kubectl create -f deployment.yaml command
7.kubectl get pods query service status 
8. Pod can view specific information: kubectl describe pods/kube-node-59bf664cbf-2qzgd

9. Reference Kubernetes pull configuration secret private warehouse mirroring official documents

kubectl create secret docker-registry myregistrykey 

--docker-server=https://index.docker.io/v1/
--docker-username=yinwensheng
--docker-password=xxxx

[email protected]

10.kubectl get secrets

So we created a secret, then the secret yaml added to the file, deployment.yaml modified file as follows:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kube-node
spec:
replicas: 2
template:
metadata:
labels:
app: web
spec:
containers:
- name: kube-node-demo-instance
image: yinwensheng/kube-node-demo1:v1
ports:
- containerPort: 8081
imagePullSecrets:
- name: myregistrykey

11.kubectl delete deployments / kube-Require

12.kubectl create -f deployment.yaml

13.kubectl get pods -o wide

14.curl 10.244.2.66:8081

15.kubectl get services /kubectl get svc nginx/

kubectl get svc nginx
curl <insert-cluster-ip-here>
 
You can view a list of running Pod and services.
kubectl get pods
kubectl get svc
kubectl cluster-info # get cluster information
 
# List namespace of all services
$ kubectl get services
# List namespace of all Pod, and provide detailed information
$ kubectl get pods -o wide
# List all namespace of all Pod
$ kubectl get pods --all-namespaces
# List specific copy controller
$ kubectl get rc <rc-name>
# List all pod with the tag env = production of
$ kubectl get pods -l env=production
 
yaml create a service exposed outside service

Guess you like

Origin www.cnblogs.com/ywsheng/p/12536985.html