In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Overview of Kubernetes
Kubernetes is an open source container orchestration engine for Google, which supports automated deployment, large-scale scalability, and application containerization management. When deploying an application in a production environment, multiple instances of the application are usually deployed to load balance application requests.
In Kubernetes, we can create multiple containers and run an application instance in each container, and then manage, discover and access this group of application instances through the built-in load balancing policy, and these details do not need to be manually configured and processed by operation and maintenance personnel.
Characteristics of Kubernetes
Portable: supports public cloud, private cloud, hybrid cloud, multiple cloud (multi-cloud)
Extensible: modular, plug-in, mountable, combinable
Automation: automatic deployment, automatic restart, automatic replication, automatic scaling / expansion
Kubernetes component
1Master component
1.1kube-apiserver
1.2ETCD
1.3kube-controller-manager
1.4cloud-controller-manager
1.5kube-scheduler
1.6 plug-in addons
1.6.1DNS
1.6.2 user interface
1.6.3 Container Resource Monitoring
1.6.4Cluster-level Logging
2-node (Node) component
2.1kubelet
2.2kube-proxy
2.3docker
2.4RKT
2.5supervisord
2.6fluentd
Two ways to create resources
1 create it on the command line:
Understand *
Json format
[root@master manifests] # pwd
/ etc/kubernetes/manifests
[root@master manifests] # vim etcd.yaml
Line 17:
-- data-dir=/var/lib/etcd
1.3imported images: nginx.tar httpd.tar
Docker load
< httpd.tar && docker load < nginx.tar 全部更新镜像: docker pull nginx //创建pod控制器,deployment [root@master ~]# kubectl run web --image=nginx --replicas=5 //查看控制器情况 [root@master ~]# kubectl get deployments. [root@master ~]# kubectl get pod/ / View resource details
[root@master] # kubectl describe deployments. Web
/ / View Namespace
[root@master ~] # kubectl get namespaces abbreviation: kubectl get ns
[root@master] # kubectl get pod-- all-namespaces
Ps: view a resource object. No namespace is specified. The default is in the defaule namespace. You can add the-n option to view the resources of the specified namespace.
For example: view the namespace of a local resource:
[root@master] # kubectl get pod-n kube-system
/ / delete pod, but there will still be
[root@master ~] # kubectl delete pod web-59765d756f-45zp6
/ / delete the controller and the pod is gone.
[root@master] # kubectl delete deployments. Test-web
/ / View details:
[root@master] # kubectl get pod-o wide
[root@master ~] # kubectl describe pod web-59765d756f-bctvr
[root@master ~] # kubectl get rs
[root@master ~] # kubectl describe rs web-59765d756f
Note: a controller resource type that is often used to run the created Deployment resource object is not only deployment, but also pod controllers such as rc,rs. Deployment is an advanced pod controller.
[root@master] # kubectl get pod-o wide
[root@master ~] # curl 10.244.2.4
Create a service resource type
[root@master] # kubectl get deployments.
[root@master] # kubectl expose deployment web--name=web-svc-- port=80-- type=NodePort
/ / View service resource types
[root@master ~] # kubectl get svc
[root@master ~] # curl 127.0.0.1purl 31351
[root@master ~] # curl 10.102.189.154
PS: if you want the public network to access the service, you can expose deployment resources and get service resources, but the type of svc resources must be NodePort.
Mapped port: 3000-32767
Expansion and reduction of service capacity
[root@master] # kubectl scale deployment web-- replicas=8
Export to json and yaml format
[root@master] # kubectl get deployments. -o json
[root@master] # kubectl get deployments. -o yaml
Export:
[root@master] # kubectl get deployments. -o yaml > web.yaml
[root@master] # kubectl edit deployments. Web
Upgrade and rollback of services:
/ / upgrade:
[root@master ~] # docker pull nginx:1.15
[root@master ~] # docker pull nginx:1.14
[root@master ~] # docker tag nginx:latest nginx:v1
[root@master ~] # kubectl set image deployment web web=nginx:1.15
[root@master] # kubectl get deployments. -o wide
[root@master ~] # kubectl get pod
[root@master] # kubectl get pod-o wide
[root@master] # kubectl get deployments. -o wide
[root@master ~] # kubectl describe pod web-ccc7c5cd6-7jlnx
[root@master] # kubectl edit deployments. Web
/ / rollback:
[root@master ~] # kubectl rollout undo deployment web
Experiment:
Sha Job:
1) to make your own image based on httpd, you need 3 versions, v1 Percience v2 Permel v3. And the content of the home directory accessed by the corresponding version image is different, which is v1:
Xxx | test-web | httpd | v1
[root@master ~] # mkdir {v1jue v2recoverv3}
[root@master ~] # cd v1
[root@master v1] # echo "songkaixiong | test-web | httpd | v1" > index.html
[root@master v1] # cat index.html
Songkaixiong | test-web | httpd | v1
[root@master v1] # cat Dockerfile
FROM httpd:latest
COPY index.html / usr/local/apache2/htdocs/index.html
[root@master v1] # docker build-t 192.168.1.10:5000/httpd:v1.
[root@master ~] # cd.. / v2 /
[root@master v2] # echo "songkaixiong | test-web | httpd | v2" > index.html
[root@master v2] # cat index.html
Songkaixiong | test-web | httpd | v2
[root@master v2] # cat Dockerfile
FROM httpd:latest
COPY index.html / usr/local/apache2/htdocs/index.html
[root@master v2] # docker build-t 192.168.1.10:5000/httpd:v2.
[root@master v2] # cd.. / v3
[root@master v3] # echo "songkaixiong | test-web | httpd | v3" > index.html
[root@master v3] # cat index.html
Songkaixiong | test-web | httpd | v3
[root@master v3] # cat Dockerfile
FROM httpd:latest
COPY index.html / usr/local/apache2/htdocs/index.html
[root@master v3] # docker build-t 192.168.1.10:5000/httpd:v3.
2) enable private warehouse registry or Harbor in the k8s cluster.
[root@master v3] # docker pull registry:2
[root@master v3] # docker run-itd-- name registry-- restart=always-p 5000 registry:2
[root@master v3] # vim / usr/lib/systemd/system/docker.service
Line 13:
ExecStart=/usr/bin/dockerd-- insecure-registry 192.168.1.10 5000
[root@master v3] # systemctl daemon-reload
[root@master v3] # systemctl restart docker
[root@master v3] # scp / usr/lib/systemd/system/docker.service node02:/usr/lib/systemd/system
[root@master v3] # scp / usr/lib/systemd/system/docker.service node03:/usr/lib/systemd/system
[root@node02 ~] # systemctl daemon-reload
[root@node02 ~] # systemctl restart docker
[root@node03 ~] # systemctl daemon-reload
[root@node03 ~] # systemctl restart docker
[root@master v3] # docker push 192.168.1.10:5000/httpd:v1
[root@master v3] # docker push 192.168.1.10:5000/httpd:v2
[root@master v3] # docker push 192.168.1.10:5000/httpd:v3
3) deploy a Deployment resource object, which requires the image to use the above private image v1 version. 6 copies of Pod.
[root@master] # kubectl run httpdtest-- image=192.168.1.10:5000/httpd:v1-- replicas=6
4) expose the above Deployment to a service resource object, so that the public network can access the service.
[root@master] # kubectl expose deployment httpdtest-name=httpd-svc-port=80-type=NodePort
5) expand and reduce the above Deployment to 8 replicas Pod, and then reduce the capacity to 4 replicas Pod.
[root@master] # kubectl scale deployment httpdtest-- replicas=8
[root@master] # kubectl scale deployment httpdtest-- replicas=4
6) upgrade and rollback the above Deployment, and upgrade v1 version to v2 version.
[root@master ~] # kubectl set image deployment httpdtest httpdtest=192.168.1.10:5000/httpd:v2
[root@master ~] # kubectl rollout undo deployment httpdtest
2 configuration list:
ApiVersion:api version Information
Kind: category of resource object
Metadata: metadata. The name field is required.
Spec: the state expected by the user.
Status: what is the state of the resource now?
Create a Deployment resource object by using a yaml file, which requires the image to use a personal private image v1 version. The replicas is 3.
[root@master ~] # vim skx.yaml
Kind: Deployment
ApiVersion: extensions/v1beta1
Metadata:
Name: web
Spec:
Replicas: 3
Template:
Metadata:
Labels:
App: web_server
Spec:
Containers:
Name: httpd
Image: 192.168.1.10:5000/httpd:v1
[root@master] # kubectl apply-f skx.yaml
Create a Service resource object by using the yaml file. To associate with the above Deployment resource object, the type type is: NodePort, and the port is: 30123.
[root@master ~] # vim skx-svc.yaml
Kind: Service
ApiVersion: v1
Metadata:
Name: skx-svc
Spec:
Type: NodePort
Selector:
App: web_server
Ports:
Protocol: TCP
Port: 80
TargetPort: 80
NodePort: 30123
[root@master] # kubectl apply-f skx-svc.yaml
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.