Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to create a docker container in K8s

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces how to create a docker container in K8s, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.

First, turn off the firewall and selinux running by the system

If the system has the firewall turned on, turn off the firewall (all machines) as follows

# systemctl stop firewalld # systemctl disable firewalld

Close selinux

# setenforce 0#sed-I'/ ^ SELINUX=/cSELINUX=disabled' / etc/sysconfig/selinux

II. MASTER installation and configuration

1. Install and configure Kubernetes master (yum mode)

# yum-y install etcd kubernetes

Configure etcd. Make sure that the items listed are configured correctly and are not commented out, as is the case with the following configurations

# vim / etc/etcd/etcd.confETCD_NAME=defaultETCD_DATA_DIR= "/ var/lib/etcd/default.etcd" ETCD_LISTEN_CLIENT_URLS= "http://0.0.0.0:2379"ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"

Configure kubernetes

Vim / etc/kubernetes/apiserverKUBE_API_ADDRESS= "- address=0.0.0.0" KUBE_API_PORT= "- port=8080" KUBELET_PORT= "- kubelet_port=10250" KUBE_ETCD_SERVERS= "- etcd_servers= http://127.0.0.1:2379"KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"KUBE_ADMISSION_CONTROL="--admission_control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota"KUBE_API_ARGS=""

two。 Start etcd, kube-apiserver, kube-controller-manager and kube-scheduler services

# for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do systemctl restart $SERVICES systemctl enable $SERVICES systemctl status $SERVICES done

3. Set up the etcd network

# etcdctl-C 10.0.0.81atomic.io/network/config 2379 set / atomic.io/network/config'{"Network": "10.1.0.0Univer 16"}'

4. At this point, the master configuration is complete, and you can run kubectl get nodes to see how much minion is running and its status. Here, none of our minion has been installed and configured, so the result is empty after running.

# kubectl get nodes NAME LABELS STATUS

3. MINION installation configuration (each minion machine is installed and configured as follows)

1. Environment installation and configuration

# yum-y install flannel kubernetes

Configure server-side IP for kubernetes connection

# vim / etc/kubernetes/configKUBE_MASTER= "--master= http://10.0.0.81:8080"KUBE_ETCD_SERVERS="--etcd_servers=http://10.0.0.81:2379"

Configure kubernetes, (please use each minion's own IP address such as 10.0.0.81: instead of the following $LOCALIP)

# vim / etc/kubernetes/kubelet

KUBELET_ADDRESS= "- address=0.0.0.0" KUBELET_PORT= "- port=10250" # change the hostname to this host's IP address KUBELET_HOSTNAME= "- hostname_override=$LOCALIP" KUBELET_API_SERVER= "- api_servers= http://10.0.0.81:8080"KUBELET_ARGS=""

two。 Prepare to start the service (if you have already run docker on the machine, please take a look, and ignore this step for those who have not)

Run ifconfig to check the network configuration of the machine (with docker0)

# ifconfig docker0Link encap:Ethernet HWaddr 02:42:B2:75:2E:67 inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0 UPBROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0errors:0 dropped:0 overruns:0 frame:0 TX packets:0errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0RX bytes:0 (0.0B) TX bytes:0 (0.0B)

Warning: you can see docker0 on the machine that has run docker. Here, delete the docker0 configuration before starting the service. Run: sudo ip link delete docker0 on the command line

3. Configure the flannel network

# vim / etc/sysconfig/flanneldFLANNEL_ETCD_ENDPOINTS= "http://10.0.0.81:2379"FLANNEL_ETCD_PREFIX="/atomic.io/network"

PS: where atomic.io corresponds to Network in the above etcd

4. Start the service

# for SERVICES in flanneld kube-proxy kubelet docker; do systemctl restart $SERVICES systemctl enable $SERVICES systemctl status $SERVICES done

IV. Completion of configuration to verify installation

Make sure that two minion (10.0.0.82 and 10.0.0.83) and one master (10.0.0.81) have been successfully installed and configured and that the services have been started. Switch to the master machine and run the command kubectl get nodes

# kubectl get nodesNAME STATUS AGE10.0.0.82 Ready 1m10.0.0.83 Ready 1m on how to create a docker container in K8s is shared here. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report