In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Create a private warehouse. # run a registry container [root@master ~] # docker run-tid-- name registry-p 5000 tid 5000-- restart always registry:latest # configure the following on all nodes that need to use a private warehouse: [root@master ~] # vim / usr/lib/systemd/system/docker.service ExecStart=/usr/bin/dockerd-H unix://-- insecure-registry 192.168.20.6 tid 500 "modify the above configuration items Specify the listening address and port of the private repository [root@master ~] # systemctl daemon-reload [root@master ~] # systemctl restart docker1) on the master node, customize an image based on the nginx image. The default interface content is changed to: Version:v1, version 2 content is: Version:v2. Version 3 content is: Version:v3 [root@master test] # vim Dockerfile # write dockerfile file FROM nginxADD index.html / usr/share/nginx/html/ [root@master test] # echo "Version:v1" > index.html # edit the first page of version 1 [root@master test] # docker build-t 192.168.20.6:5000/ljz:v1. # make version 1 image # make version 2 image [root@master test] # echo "Version:v2" > index.html [root@master test] # docker build-t 192.168.20.6:5000/ljz:v2. # make version 3 image [root@master test] # echo "Version:v3" > index.html [root@master test] # docker build-t 192.168.20.6:5000/ljz:v3. # put on the above three images Send it to the private repository [root@master test] # docker push 192.168.20.6:5000/ljz:v1 [root@master test] # docker push 192.168.20.6:5000/ljz:v2 [root@master test] # docker push 192.168.20.6:5000/ljz:v32) to create a Namespace. All the next operations are under this namespace. [root@master test] # vim ns.yaml # write the yaml file apiVersion: v1kind: Namespacemetadata: name: lvjianzhao [root@master test] # kubectl apply-f ns.yaml # run the yaml file namespace/lvjianzhao created [root@master test] # kubectl get ns lvjianzhao # to view the created namespace. NAME STATUS AGElvjianzhao Active 11s
Create a Deployment resource object. The mirror version is v1.
[root@master test] # vim lvjianzhao.yaml # write yaml file apiVersion: extensions/v1beta1kind: Deploymentmetadata: name: lvjianzhao namespace: lvjianzhaospec: revisionHistoryLimit: 5 # specify how many versions to record This field uses the kubectl explain deploy.spec command to find the revisionHistoryLimit line to get replicas: 2 template: metadata: labels: name: lvjianzhaoa spec: containers:-name: lvjianzhao image: 192.168.20.6:5000/ljz:v1 # Image version 1 ports:-containerPort: 80 [root@master test] # kubectl apply-f lvjianzhao.yaml-- record # execute the yaml file -- record means to record version history [root@master test] # kubectl get pod # look at the podNo resources found.# running in the above yaml file. It can be concluded that if you specify which namespace,# you belong to when writing the yaml file, then the above command cannot view the running pod, instead of the pod [root@master test] # kubectl get pod-n lvjianzhao # without running add "- n" option and specify the namespace. You can see the corresponding podNAME READY STATUS RESTARTS AGElvjianzhao-865d4b6b6-2mlcj 1 Running 0 101slvjianzhao-865d4b6b6-7kbnb 1 Running 0 101s [root@master test] # kubectl rollout history deployment-n lvjianzhao lvjianzhao # View the deployment resource object deployment.extensions/lvjianzhao REVISION CHANGE-CAUSE1 kubectl apply-- filename=lvjianzhao.yaml-- record=true of lvjianzhao's namespace namespace named deployment # you can see that there is currently only one version 3) create a Service resource object Associate to the Deployment resource object above. [root@master test] # vim ljz-svc.yaml # create the yaml file of service apiVersion: v1kind: Servicemetadata: name: lvjianzhao-service namespace: lvjianzhaospec: type: NodePort selector: name: lvjianzhaoa ports:-name: lvjianzhao-port port: 8080 # this is service's IP port targetPort: 80 # this is pod's port nodePort: 31111 # this is the port mapped to the host [root@master test] # kubectl apply-f Ljz-svc.yaml # execute yaml file service/lvjianzhao-service created [root@master test] # kubectl get svc # in the same way If you do not specify a namespace The NAME TYPE CLUSTER-IP EXTERNAL-IP PORT (S) AGEkubernetes ClusterIP 10.96.0.1 443/TCP 4d1h [root@master test] # kubectl get svc-n lvjianzhao # of the corresponding service was not found. Use the "- n" option to view the serviceNAME TYPE CLUSTER-IP EXTERNAL-IP PORT (S) AGElvjianzhao-service in the specified namespace. NodePort 10.104.119.94 8080:31111/TCP 111s
Note: the created service resource object must be in the same namespace as the created deployment resource object, otherwise it cannot be associated!
The client can now access port 31111 of any node in the k8s cluster to access the services provided by its pod, as follows:
If you need to modify the web page file provided by pod online, you can first view the name of pod, and then log in to the pod directly on the master node, as follows:
[root@master httpd-web] # kubectl get pod-o wide # View pod's nameNAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATEShttpd-devploy1-6f987c9764-5g92w 1 Running 0 8m35s 10.244.1.5 node01 httpd-devploy1-6f987c9764-wvgft 1 Running 0 [root@master httpd -web] # kubectl exec-it httpd-devploy1-6f987c9764-5g92w / bin/bash # by specifying the name of the pod Enter pod now from version 1, scroll to version 2, then to version 3, and finally roll back to the specified version 1 content. [root@master test] # sed-I's kubectl apply LJZ lvjianzhao.yaml v1 stop LJZ lvjianzhao.yaml # change to version 2 [root@master test] # LJZ-f lvjianzhao.yaml # execute deployment.extensions/lvjianzhao configured [root@master test] # curl 127.0.1 kubectl rollout history deployment-n lvjianzhao lvjianzhao # access Authentication Version: v2 [root @ master test] # kubectl rollout history deployment-n lvjianzhao lvjianzhao # check the historical version again Kubectl apply-- filename=lvjianzhao.yaml-- record=true2 # now has two historical versions # and then upgrade and verify [root@master test] # sed-I's Version again and verify that [lvjianzhao.yaml [root@master test] # kubectl apply-f lvjianzhao.yaml [root@master test] # curl 127.0.0.1 curl 31111 # is now version 3 Version: v3 [root @ master test] # kubectl rollout history Deployment-n lvjianzhao lvjianzhao # View historical version information deployment.extensions/lvjianzhao REVISION CHANGE-CAUSE1 kubectl apply-- filename=lvjianzhao.yaml-- record=true2 3 # now perform a rollback operation: [root@master test] # kubectl rollout undo deployment-n lvjianzhao lvjianzhao-- to-revision=1 # rollback to version 1 You need to specify namespace, and "--to-revision" specifies the version to which deployment.extensions/lvjianzhao rolled back [root@master test] # curl 127.0.0.1 deployment.extensions/lvjianzhao rolled back 31111 # verifies Version: v1 [root @ master test] # kubectl rollout history deployment-n lvjianzhao lvjianzhao # checks the history again and finds that version 1 has become version 4. Deployment.extensions/lvjianzhao REVISION CHANGE-CAUSE2 3 4 kubectl apply-filename=lvjianzhao.yaml-record=true
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.