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--
Kubernetes cluster release Pod port creation test environment vi nginx.yamlapiVersion: apps/v1kind: Deploymentmetadata: name: my-nginxspec: selector: matchLabels: run: my-nginx replicas: 2 template: metadata: labels: run: my-nginxspec: containers:-name: my-nginx image: nginx ports:-containerPort: 80 Verification Service starts [root@kubm-02 ~] # kubectl get podsNAME READY STATUS RESTARTS AGEmy-nginx-756fb87568-jwgp8 1 Running 0 64smy-nginx-756fb87568-vshxc 1 Running 0 64s [root @ kubm-02 ~] # [root@kubm-02 ~] # kubectl get pods-l run=my-nginx-o wideNAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATESmy-nginx-756fb87568-jwgp8 1 Running 0 2m12s 10.244.3.101 kubnode-01 my-nginx-756fb87568-vshxc 1 Running 0 2m12s 10.244.123 kubnode-02 check the IP address of Pod: [root@kubm-02 ~] # kubectl get pods-l run=my-nginx-o yaml | grep podIP podIP : 10.244.3.101 podIP: 10.244.4.123 create Service
Kubernetes Service logically defines a set of Pod running in a cluster that provide the same functionality. When each Service is created, it is assigned a unique IP address (also known as clusterIP). This IP address is tied to the life cycle of a Service, and it does not change when the Service exists. Pod can be configured to communicate with Service, and Pod knows that communication with Service will be automatically load balanced to some Pod in that Service.
Create a nginx service
The kubectl expose command creates a Service for 2 copies of Nginx:
[root@kubm-02 ~] # kubectl expose deployment/my-nginxservice/my-nginx exposed Verification Service starts [root@kubm-02 ~] # kubectl get svcNAME TYPE CLUSTER-IP EXTERNAL-IP PORT (S) AGEmy-nginx ClusterIP 10.245.206.203 80/TCP 2m36s View details [root@kubm-02 ~] # kubectl describe svc my-nginxName: my-nginxNamespace: DefaultLabels: Annotations: Selector: run=my-nginxType: ClusterIPIP: 10.245.206.203Port: 80/TCPTargetPort: 80/TCPEndpoints: 10.244.3.101 my-nginx pod 80 session Affinity: NoneEvents: kubectl describe po my-nginx # View the Detailed status kubectl describe rs my-nginx # View detailed status of my-nginx replica set kubectl describe deployment my-nginx # View detailed status of my-nginx deployment access Service
Kubernetes supports two main service discovery modes-environment variables and DNS. The former is available on a single node, while the latter must use the kube-dns cluster plug-in.
[root@kubm-02 ~] # kubectl get podsNAME READY STATUS RESTARTS AGEmy-nginx-756fb87568-jwgp8 1 kubectl get podsNAME READY STATUS RESTARTS AGEmy-nginx-756fb87568-jwgp8 1 Running 0 23mmy-nginx-756fb87568-vshxc 1 Running 0 23m [root @ kubm-02 ~] # kubectl exec my-nginx-756fb87568-jwgp8-- printenv | grep SERVICE KUBERNETES_SERVICE_HOST=10.245.0.1KUBERNETES_SERVICE_PORT=443KUBERNETES_SERVICE_PORT_HTTPS=443DNS parsing test
Kubernetes provides DNS. If it is running in the cluster, you can check it with the following command:
[root@kubm-02] # kubectl get services kube-dns-- namespace=kube-systemNAME TYPE CLUSTER-IP EXTERNAL-IP PORT (S) AGEkube-dns ClusterIP 10.245.0.10 53 Universe UDP 9153/TCP 11d verification service parsing starts an image with curl installed [root@kubm-02 ~] # kubectl run curl--image=radial/busyboxplus:curl-I-- tty test parses my-nginx [root@curl-6bf6db5c4f-96nhg:/] $nslookup my-nginxServer: 10.245.0.10 "= dns server Address 1: 10.245.0.10 kube-dns .kube-system.svc.cluster.localName: my-nginxAddress 1: 10.245.206.203 my-nginx.default.svc.cluster.local "= = the cluster IP address of the my-nginx service [root@curl-6bf6db5c4f-96nhg:/] $curl test [root@curl-6bf6db5c4f-96nhg:/] $curl my-nginx .Welcome to nginxaddresses. [root@curl-6bf6db5c4f-96nhg:/] $curl 10.245.206.203.Welcome to nginx!. Service resource expansion and contraction service [root@kubm-02] # kubectl scale deployment my-nginx-- replicas=0 verification [root@kubm-02] # kubectl get pods-o wide
No resources found.
Expand the service to 2 nodes [root@kubm-02 ~] # kubectl scale deployment my-nginx--replicas=2deployment.extensions/my-nginx scaled verify [root@kubm-02 ~] # kubectl get pods-o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATESmy-nginx-756fb87568-gmgfq 0max 1 ContainerCreating 0 1s Kubnode-02 my-nginx-756fb87568-gvhbm 0 ContainerCreating 1 ContainerCreating 0 1s kubnode-01 cleanup Service # directly use the profile to delete [root@kubm-02 ~] # kubectl delete-f nginx.yaml deployment.apps "my-nginx" deleted# deletion Service [root@kubm-02 ~] # kubectl get svcNAME TYPE CLUSTER-IP EXTERNAL-IP PORT (S) AGEkubernetes ClusterIP 10.245.0.1 443/TCP 11dmy-nginx ClusterIP 10.245.206.203 80/TCP 48m [root @ kubm-02] # kubectl delete svc my-nginx service "my-nginx" deleted [root @ kubm-02 ~] # kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT (S) AGEkubernetes ClusterIP 10. 245.0.1 443/TCP 11d
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.