daemon.json
{
"registry-mirrors": ["https://da5263ax.mirror.aliyuncs.com","https://registry.docker-cn.com"],
"bip": "10.1.1.1/8",
"mtu": 1500,
"dns": ["8.8.8.8"],
"insecure-registries": ["pend2","192.168.8.7"]
}
DOCKER_HOST=tcp://
curl pend1:2375/version
kubeadm:
- kubernetes(yum源)
cat > /etc/yum.repos.d/kubernetes.repo <<-eof
[kubenetes]
name=kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
eofyum install kubelet kubeadm kubectl
systemctl enable kubelet && systemctl start kubelet
- docker-ce
wget -P /etc/yum.repos.d https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum install -y docker-ce
systemctl start docker && systemctl enable docker - cat > /etc/sysctl.d/k8s.conf <<-eof
net.bridge.bridge-nf-call-ip6tables=1
net.bridge.bridge-nf-call-iptables=1
eof
sysctl --system - tee -a /etc/docker/daemon.json <<-eof
{
"registry-mirrors": ["https://f1791z1h.mirror.aliyuncs.com"]
}
eof
systemctl daemon-reload && systemctl restart docker - /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS="--fail-swap-on=false" - kubeadm init --kubernetes-version=1.18.0 \
--apiserver-advertise-address=192.168.8.6 \
--image-repository registry.aliyuncs.com/google_containers \
--pod-network-cidr=10.244.0.0/16 \
--service-cidr=10.96.0.0/12 \
--ignore-preflight-errors=swap
1 [root@pend1 ~]# kubeadm init --kubernetes-version=1.18.0 --apiserver-advertise-address=192.168.8.6 --image-repository registry.aliyuncs.com/google_containers --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --ignore-preflight-errors=swap 2 W0624 22:53:13.569789 25829 configset.go:202] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io] 3 [init] Using Kubernetes version: v1.18.0 4 [preflight] Running pre-flight checks 5 [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/ 6 [WARNING Swap]: running with swap on is not supported. Please disable swap 7 [preflight] Pulling images required for setting up a Kubernetes cluster 8 [preflight] This might take a minute or two, depending on the speed of your internet connection 9 [preflight] You can also perform this action in beforehand using 'kubeadm config images pull' 10 [kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env" 11 [kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml" 12 [kubelet-start] Starting the kubelet 13 [certs] Using certificateDir folder "/etc/kubernetes/pki" 14 [certs] Generating "ca" certificate and key 15 [certs] Generating "apiserver" certificate and key 16 [certs] apiserver serving cert is signed for DNS names [pend1 kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 192.168.8.6] 17 [certs] Generating "apiserver-kubelet-client" certificate and key 18 [certs] Generating "front-proxy-ca" certificate and key 19 [certs] Generating "front-proxy-client" certificate and key 20 [certs] Generating "etcd/ca" certificate and key 21 [certs] Generating "etcd/server" certificate and key 22 [certs] etcd/server serving cert is signed for DNS names [pend1 localhost] and IPs [192.168.8.6 127.0.0.1 ::1] 23 [certs] Generating "etcd/peer" certificate and key 24 [certs] etcd/peer serving cert is signed for DNS names [pend1 localhost] and IPs [192.168.8.6 127.0.0.1 ::1] 25 [certs] Generating "etcd/healthcheck-client" certificate and key 26 [certs] Generating "apiserver-etcd-client" certificate and key 27 [certs] Generating "sa" key and public key 28 [kubeconfig] Using kubeconfig folder "/etc/kubernetes" 29 [kubeconfig] Writing "admin.conf" kubeconfig file 30 [kubeconfig] Writing "kubelet.conf" kubeconfig file 31 [kubeconfig] Writing "controller-manager.conf" kubeconfig file 32 [kubeconfig] Writing "scheduler.conf" kubeconfig file 33 [control-plane] Using manifest folder "/etc/kubernetes/manifests" 34 [control-plane] Creating static Pod manifest for "kube-apiserver" 35 [control-plane] Creating static Pod manifest for "kube-controller-manager" 36 W0624 22:54:20.213586 25829 manifests.go:225] the default kube-apiserver authorization-mode is "Node,RBAC"; using "Node,RBAC" 37 [control-plane] Creating static Pod manifest for "kube-scheduler" 38 W0624 22:54:20.216439 25829 manifests.go:225] the default kube-apiserver authorization-mode is "Node,RBAC"; using "Node,RBAC" 39 [etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests" 40 [wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s 41 [apiclient] All control plane components are healthy after 23.512374 seconds 42 [upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace 43 [kubelet] Creating a ConfigMap "kubelet-config-1.18" in namespace kube-system with the configuration for the kubelets in the cluster 44 [upload-certs] Skipping phase. Please see --upload-certs 45 [mark-control-plane] Marking the node pend1 as control-plane by adding the label "node-role.kubernetes.io/master=''" 46 [mark-control-plane] Marking the node pend1 as control-plane by adding the taints [node-role.kubernetes.io/master:NoSchedule] 47 [bootstrap-token] Using token: 3kjypa.u6ggfr58t3g8hg3m 48 [bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles 49 [bootstrap-token] configured RBAC rules to allow Node Bootstrap tokens to get nodes 50 [bootstrap-token] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials 51 [bootstrap-token] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token 52 [bootstrap-token] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster 53 [bootstrap-token] Creating the "cluster-info" ConfigMap in the "kube-public" namespace 54 [kubelet-finalize] Updating "/etc/kubernetes/kubelet.conf" to point to a rotatable kubelet client certificate and key 55 [addons] Applied essential addon: CoreDNS 56 [addons] Applied essential addon: kube-proxy 57 58 Your Kubernetes control-plane has initialized successfully! 59 60 To start using your cluster, you need to run the following as a regular user: 61 62 mkdir -p $HOME/.kube 63 sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config 64 sudo chown $(id -u):$(id -g) $HOME/.kube/config 65 66 You should now deploy a pod network to the cluster. 67 Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at: 68 https://kubernetes.io/docs/concepts/cluster-administration/addons/ 69 70 Then you can join any number of worker nodes by running the following on each as root: 71 72 kubeadm join 192.168.8.6:6443 --token 3kjypa.u6ggfr58t3g8hg3m \ 73 --discovery-token-ca-cert-hash sha256:f4a72ecda89ed92f69c35e836e39efae91bbb63ad03bceab7b5c37c0bba27856
- mkdir -pv $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config - kubectl get componentstatus|cs
- kubectl get nodes
- 安装calico网络
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml