前置条件
安装 docker
https://download.docker.com/linux/static/stable/
修改系统参数
1 | $ cat <<EOF | tee /etc/sysctl.d/k8s.conf |
swapoff -a && sysctl -w vm.swappiness=0
cat /proc/swaps
free
blkid
lsblk
1 |
|
cat /sys/class/dmi/id/product_uuid
1 |
|
ip a
ifconfig -a
1
2
### 端口占用检查
yum install -y net-tools
netstat -ntlp | grep -E '6443|23[79,80]|1025[0,1,2]'
1 |
|
yum install -y socat
apt-get install -y socat
1 |
|
cat <
[Unit]
Description=kubelet: The Kubernetes Agent
Documentation=http://kubernetes.io/docs/
[Service]
ExecStart=/usr/bin/kubelet
Restart=always
StartLimitInterval=0
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
1 |
|
mkdir -p /etc/systemd/system/kubelet.service.d
cat <
[Service]
Environment=“KUBELET_KUBECONFIG_ARGS=–bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf”
Environment=“KUBELET_CONFIG_ARGS=–config=/var/lib/kubelet/config.yaml”
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
EnvironmentFile=-/etc/default/kubelet
ExecStart=
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS
EOF
1 |
|
systemctl enable kubelet
systemctl start kubelet
systemctl status kubelet
1 |
|
kubeadm init --pod-network-cidr=10.244.0.0/16 --image-repository=registry.aliyuncs.com/google_containers --kubernetes-version=v1.15.0
1 |
|
mkdir -p $HOME/.kube
cp /etc/kubernetes/admin.conf $HOME/.kube/config
chown (id -g) $HOME/.kube/config
1 |
|
wget https://github.com/containernetworking/plugins/releases/download/v0.8.1/cni-plugins-linux-amd64-v0.8.1.tgz
tar -xzvf cni-plugins-linux-amd64-v0.8.1.tgz -C /opt/cni/bin/
1 |
|
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
1 |
|
kubectl get nodes -o yaml | grep message
1 |
|
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
1 |
|
kubectl create -f dashboard-admin.yaml
1 |
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: kubernetes-dashboard
labels:
k8s-app: kubernetes-dashboard
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: kubernetes-dashboard
namespace: kube-system
1 |
|
kubectl -n kube-system edit service kubernetes-dashboard
1 |
|
kubectl -n kube-system get service kubernetes-dashboard
1 |
|
https://
1 |
|
https://
1 |
|
kubectl -n kube-system get serviceaccount -l k8s-app=kubernetes-dashboard -o yaml
kubectl -n kube-system describe secrets kubernetes-dashboard-token-xxa48
1 |
|
kubeadm config print init-defaults
1 |
|
kubeadm config images list --kubernetes-version=v1.15.0
k8s.gcr.io/kube-apiserver:v1.15.0
k8s.gcr.io/kube-controller-manager:v1.15.0
k8s.gcr.io/kube-scheduler:v1.15.0
k8s.gcr.io/kube-proxy:v1.15.0
k8s.gcr.io/pause:3.1
k8s.gcr.io/etcd:3.3.10
k8s.gcr.io/coredns:1.3.1
参考资料:
<https://godoc.org/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1>