In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to build a stand-alone version of kubernetes cluster". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to build a stand-alone kubernetes cluster".
I. Environmental preparation
1. Install etcd and kubernetes under CentOS7
[root@jin-120 ~] # yum install-y etcd kubernetes
2. Turn off the firewall and set the boot not to start
[root@jin-120 ~] # systemctl stop firewall [root @ jin-120 ~] # systemctl disable firewalld
3. Modify the configuration file / etc/sysconfig/docker and set the content of OPTIONS to:
OPTIONS='--selinux-enabled=false-insecure-registry grc.io-log-driver=journald-signature-verification=false'
Then modify the kubernetes apiserver configuration file / etc/kubernetes/apiserver to delete the ServiceAcconut in the-- ADMISSION_CONTROL parameter.
4. Start all the following services in order:
For i in etcd docker kube-apiserver kube-controller-manager kube-scheduler kubelet kube-proxydo systemctl start $idone
At this point, our stand-alone kubernetes cluster environment is installed.
2. Start MySQL service
1. Create a RC definition file mysql-rc.yaml for MySQL service, which is as follows:
ApiVersion: v1kind: ReplicationControllermetadata: name: mysqlspec: replicas: 1 selector: app: mysql template: metadata: labels: app: mysqlspec: containers:-name: mysql image: mysql:5.6 ports:-containerPort: 3306 env:-name: MYSQL_ROOT_PASSWORD value: "123456"
2. Execute the command kubectl create-f mysql-rc.yaml to create the RC, and then use the command kubectl get rc to view the created RC:
[root@jin-120 ~] # kubectl create-f mysql-rc.yamlreplicationcontroller "mysql" created [root @ jin-120 ~] # kubectl get rcNAME DESIRED CURRENT READY AGEmysql 1 1 1 1m
Then look at the pod generated by the RC definition:
[root@jin-120 ~] # kubectl get podNAME READY STATUS RESTARTS AGEmysql-xcgj0 1amp 1 Running 0 1m
3. Let's create another file about MySQL service: vim mysql-svc.yaml, which is as follows:
ApiVersion: v1kind: Servicemetadata: name: mysqlspec: ports:-port: 3306 selector: app: mysql
Run the command to create the service:
[root@jin-120 ~] # kubectl create-f mysql-svc.yaml service "mysql" created
Check to see if it was created successfully:
[root@jin-120] # kubectl get svcNAME CLUSTER-IP EXTERNAL-IP PORT (S) AGEkubernetes 10.254.0.1 443/TCP 1dmysql 10.254.70.236 3306/TCP 11s
As you can see, MySQLservice is assigned a Cluster IP of 10.254.70.236 so that other newly created Pod in the kubernetes cluster can be connected and accessed through service's Cluster IP+port6379.
3. Launch Tomcat application
1. Create the corresponding RC file myweb-rc.yaml, which is as follows:
Kind: ReplicationControllermetadata: name: mywebspec: replicas: 1 selector: app: myweb template: metadata: labels: app: mywebspec: containers:-name: myweb image: kubeguide/tomcat-app:v1 ports:-containerPort: 8080 env:-name: MYSQL_SERVICE_HOST value: 'mysql'-name: MYSQL_SERVICE_PORT value: '3306'
2. Execute the command kubectl create-f myweb-rc.yaml to create the RC, and then use the command kubectl get rc to view the created RC:
[root@jin-120 ~] # kubectl create-f myweb-rc.yaml replicationcontroller "myweb" created [root @ jin-120 ~] # kubectl get rcNAME DESIRED CURRENT READY AGEmysql 1 1 1 13mmyweb 1 1 1 16s
Then look at the pod generated by the RC definition:
[root@jin-120 ~] # kubectl get podsNAME READY STATUS RESTARTS AGEmysql-xcgj0 1 kubectl get podsNAME READY STATUS RESTARTS AGEmysql-xcgj0 1 Running 2 15mmyweb-jmll1 1 Running 0 1m
3. Let's create another file about myweb service: vim myweb-svc.yaml, which is as follows:
ApiVersion: v1kind: Servicemetadata: name: mywebspec: type: NodePort ports:-port: 8080 nodePort: 30001 selector: app: myweb
Create and view the created service:
[root@jin-120 ~] # kubectl create-f myweb-svc.yaml service "myweb" create [root @ jin-120 ~] # kubectl get svcNAME CLUSTER-IP EXTERNAL-IP PORT (S) AGEkubernetes 10.254.0.1 443/TCP 1dmysql 10.254.70.236 3306/TCP 13mmyweb 10.254.218.251 8080:30001/TCP 9s
At this point, our cluster has been built.
IV. Testing
Enter the address in the browser: http:// virtual machine IP:30001/demo/:
Seeing the web page above shows that the stand-alone kubernetes cluster we built is successful.
We can try to click the "Add" button to add a record and submit it, after which the data will be written to the MySQL database.
Thank you for reading, the above is the content of "how to build a stand-alone version of kubernetes cluster". After the study of this article, I believe you have a deeper understanding of how to build a stand-alone version of kubernetes cluster, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.