In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how to use kubernetes, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
1 main and standby host centos
2 turn off the firewall
Systemctl stop firewalld & & systemctl disable firewalld
3 install etcd and kubernetes
Yum install etcd kubernetes-y
3 modify docker configuration file
Add-- insecure-registry gcr.io after the OPTIONS parameter to the docker configuration file / etc/sysconfig/docker, as follows:
4 modify kubernetes configuration file
Delete the ServiceAccount in parameter KUBE_ADMISSION_CONTROL in the configuration file / etc/kubernetes/apiserver
5 start the kubectl service at once
Systemctl start etcd
Systemctl start docker
Systemctl start kube-apiserver
Systemctl start kube-controller-manager
Systemctl start kube-scheduler
Systemctl start kubelet
Systemctl start kube-proxy
6 download the image required for the case
Docker pull docker.io/kubeguide/redis-master
Dokcer pull docker.io/kubeguide/guestbook-redis-slave
Docker pull docker.io/kubeguide/guestbook-php-frontend
Docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest
When pulling the image registry.access.redhat.com/rhel7/pod-infrastructure:latest, an error may be reported and cannot be pulled down. Solution:
Yum install-y * rhsm*
Wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm
Rpm2cpio python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm | cpio-iv-- to-stdout. / etc/rhsm/ca/redhat-uep.pem | tee / etc/rhsm/ca/redhat-uep.pem
Re-pull registry.access.redhat.com/rhel7/pod-infrastructure:latest, this mirror is slow to pull, please wait patiently.
7 create RC and service for redis-master
# write the yaml file of rc [root@node1 redis] # cat redis-master-controller.yaml apiVersion: v1kind: ReplicationControllermetadata: name: redis-master / / rc name labels: name: redis-master / / rc tag spec: replicas: 1 / / rc create the number of copies of pod selector: name: redis-master / / tag selector used by rc template: / / use templates to create tags used by pod created by pod metadata: labels: name: redis-master / / This must be consistent with the above rc tag selector spec: containers:-name: master image: kubeguide/redis-master ports:-containerPort: 637creating rckubectl create-f. / redis-master-controller.yaml [root@node1 redis] # kubectl get rc | grep masterredis-master 11 15h [root@node1 redis] # kubectl get pods | grep masterredis-master-k9k5n 1 / 1 Running 0 5h# write the yaml file of service [root@node1 redis] # cat redis-master-service.yaml apiVersion: v1kind: Servicemetadata: redis-master labels: name: redis-masterspec: ports:-port: 6379 # service Virtual Port targetPort: 6379 # pod managed by service selector: name: Redis-master # the tag selector here should be the same as the tag that created pod in the above RC file # create servicekubectl create-f. / redis-master-service.yaml [root@node1 redis] # kubectl get services | grep masterredis-master 10.254.38.172 6379/TCP 2h
8 create RC and service for redis-slave
[root@node1 redis] # cat redis-slave-controller.yaml apiVersion: v1kind: ReplicationControllermetadata: name: redis-slave labels: name: redis-slavespec: replicas: 2 selector: name: redis-slave template: metadata: labels: name: redis-slavespec: containers:-name: slave image: kubeguide/guestbook-redis-slave env:-name: GET_HOSTS_FROM value: Env ports:-containerPort: 6379 [root@node1 redis] # kubectl get pods | grep slaveredis-slave-dt0vk 1 kubectl get pods 1 Running 0 2hredis-slave-lf79v 1 Running 02 h [root@node1 redis] # cat redis-slave-service.yaml apiVersion: v1kind: Servicemetadata: name: redis-slave labels: name: redis-slavespec: ports:-port: 6379 targetPort: 6379 selector: name: redis- Slave [root@node1 redis] # kubectl get services | grep slaveredis-slave 10.254.194.253 6379/TCP 2h
9 create RC and service for frontend
[root@node1 redis] # cat frontend-controller.yaml apiVersion: v1kind: ReplicationControllermetadata: name: frontend labels: name: frontendspec: replicas: 3 selector: name: frontend template: metadata: labels: name: frontendspec: containers:-name: frontend image: kubeguide/guestbook-php-frontend env:-name: GET_HOSTS_FROM value: env ports: -containerPort: 80 [root@node1 redis] # cat frontend-service.yaml apiVersion: v1kind: Servicemetadata: frontend labels: name: frontendspec: type: NodePort ports:-port: 80 nodePort: 30001 selector: name: frontend# because frontend services require external access Therefore, the virtual port of service needs to be mapped to the host, so the nodePort port is added. The range of # nodePort is 30000 to 32767, otherwise an error will be reported. [root@node1 redis] # kubectl get pods | grep frontfrontend-069sm 1 Running 0 2hfrontend-bksm5 1 Running 0 2hfrontend-q2vpv 1 kubectl get rc 1 Running 0 h [root@node1 redis] # kubectl get rc | grep frontfrontend 3 3 32 h [root@node1 redis] # kubectl get service | grep frontfrontend 10.254.27.214 80:30001/TCP 2h
9 experiment
Thank you for reading this article carefully. I hope the article "how to use kubernetes" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.