一. 环境搭建:
3 CENTOS7 hosts:
Master 192.168.1.140 deploys Etcd,kube-apiserver,kube-controller-manager,kube-scheduler 4 apps.
NODE01 192.168.1.31 Deployment Docker,kubelet, Kube-proxy 3 apps
NODE02 192.168.1.11 Deployment Docker,kubelet, Kube-proxy 3 apps
- modifies the hostname and IP, and the three host NICs are set to bridged mode, enabling networking.
- Modify the/etc/hosts file individually:
- Three sets the default zone for the firewall to trusted.
- All three have the selinux turned off.
The
- installs Docker and starts. Since master also needs to do the registry warehouse, it also needs to install Docker.
- turn on route forwarding:
Two. Implements the container interoperability between NODE01 and NODE02.
- node01 and Node02 create a new bridge and secure the bridge IP.
Node01:
Delete the bridge Docker0, create a new bridge Kbr0:
New Network Bridge configuration file:
New route file: Route-eth0,eth0 is the name of the network adapter on the Node1.
Modify the Docker configuration file, add the-b=kbr0 parameter
Reboot Restart the system for the bridge settings to take effect.
- do the same for NODE02:
New bridge:
New bridge Profile:
Create route file:
Modify Docker profile:
Restart system reboot.
- after the system starts, view the network card information and routing information.
- verifies the interoperability of containers between two host hosts:
Node01 runs a container on
Node02:
Inter-container ping:
Three. Deploy the app on master:
- install ETCD.
View Etcd profile:
- Modify Profile:
- start ETCD service:
View service port number:
- Deploy K8s-master components (apiserver +controller-manager+scheduler)
Install software:
View profile:
- Modify Profile:
Kube_logtostderr//Log settings
Kube_log_kevel//Log level settings
Kube_allow_priv//Whether privileged containers are allowed to run
Kube_master//Master node address, mainly for replication controller and Scheduler and Kubelet can be found successfully apiserver
Kube_api_address//monitoring interface, if configured as 127.0.0.1 only listens to localhost, configured to 0.0.0.0 will listen to all interfaces, here configured to 0.0.0.0.
Kube_api_port= "--port=8080"//apiserver listening port, default 8080, without modification.
kubelet_port= "--kubelet_port=10250"//Kubelet listening port, default 10250, no need to modify
Kube_etcd_servers//Specify the address of the ETCD node
Kube_service_addresses//This is the IP network segment where the SERVICE will run in the future
kube_api_args= "--secure-port=0"//default is to require HTTPS secure communication, "--secure-port=0" does not require HTTPS secure communication
Note: It is necessary to note that the original Kube_admission_control default contains to be deleted, or start the API server when the error
- Start the service:
To view the service port:
Four Deploy node Host:
- Install Kubernetes-node Software:
To view the configuration file:
- To modify a configuration file:
Configuration Item Kubelet_pod_infra_container= "--pod-infra-container-image=registry.access.redhat.com/rhel7/ Pod-infrastructure:latest "function k8s a basic container is needed when creating pods, so node nodes should be able to connect to the network. You can also build a private warehouse, upload the pod-infrastructure:latest image to a private repository, and modify the address of this profile.
- Start the service:
To view ports:
- Repeat the above operation on the NODE02 host.
Check the node status on master:
Five Building a private warehouse:
Kubernetes Management Container If this is the first operation, there may be some waiting time, because the first download of images takes a while. If there is no Docker registry locally, make sure that the nodes have access to the Internet, so we can build a private warehouse that provides the required mirrors by a private warehouse.
In this experimental environment, Kubernetes is used as registry.
- Import Image:
- Run a container based on a private warehouse image
Local access to private repositories:
- Upload the image to a private warehouse.
Images used after import to local:
To label the underlying image:
Modify the Docker configuration file on all three hosts, specifying the URL of the private warehouse.
To restart the Docker service:
Upload the image to a private repository and view:
Test, download the image you just uploaded:
At this point, the cluster is completed.
Kubernetes Cluster deployment