标签:roc tst cts status none ocs domain fail account
签发kubelet证书
vi /opt/certs/kubelet-csr.json
{
"CN": "k8s-kubelet",
"hosts": [
"127.0.0.1",
"192.168.17.50",
"192.168.17.51",
"192.168.17.52",
"192.168.17.53",
"192.168.17.54",
"192.168.17.55",
"192.168.17.56",
"192.168.17.57",
"192.168.17.58"
],
"key": {
"algo": "rsa",
"size": 2048
},
"names": [
{
"C": "CN",
"ST": "beijing",
"L": "beijing",
"O": "od",
"OU": "ops"
}
]
}
cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=server kubelet-csr.json |cfssljson -bare kubelet
把证书拷贝到各个运算节点中
scp kubelet.pem kubelet-key.pem 192.168.17.54:/opt/kubernetes/server/bin/cert
创建kubelet配置生成kubeconfig 四步骤
kubectl config set-cluster myk8s \
--certificate-authority=/opt/kubernetes/server/bin/cert/ca.pem \
--embed-certs=true \
--server=https://192.168.17.50:7443 \
--kubeconfig=kubelet.kubeconfig
kubectl config set-credentials k8s-node \
--client-certificate=/opt/kubernetes/server/bin/cert/client.pem \
--client-key=/opt/kubernetes/server/bin/cert/client-key.pem \
--embed-certs=true \
--kubeconfig=kubelet.kubeconfig
kubectl config set-context myk8s-context \
--cluster=myk8s \
--user=k8s-node \
--kubeconfig=kubelet.kubeconfig
kubectl config use-context myk8s-context --kubeconfig=kubelet.kubeconfig
授予权限,角色绑定 -- 只创建一次就好,存到etcd里,然后拷贝到各个node节点上
vi k8s-node.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: k8s-node
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:node
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: User
name: k8s-node
kubectl create -f k8s-node.yaml
kubectl get clusterrolebinding k8s-node -o yaml
拷贝kubelet.kubeconfig到另外一台机器
准备pause基础镜像 -- 边车模式 必须先与业务容器受kubectl控制去先占用空间
docker login harbor.od.com
docker pull kubernetes/pause
docker tag f9d5de079539 harbor.od.com/public/pause:latest
docker push harbor.od.com/public/pause:latest
配置kubectl启动脚本
vi /opt/kubernetes/server/bin/kubelet.sh
./kubelet \
--kubeconfig ./conf/kubelet.kubeconfig
--fail-swap-on=false
--cgroup-driver systemd
--anonymous-auth=false
--client-ca-file ./cert/ca.pem
--tls-cert-file ./cert/kubelet.pem
--tls-private-key-file ./cert/kubelet-key.pem
--hostname-override k8s3.host.com
--cluster-dns 192.168.0.2
--cluster-domain cluster.local
--runtime-cgroups=/systemd/system.slice
--kubelet-cgroups=/systemd/system.slice
--kubeconfig ./conf/kubelet.kubeconfig
--root-dir /data/kubelet
--pod-infra-container-image harbor.od.com/public/pause:latest
创建目录
mkdir -p /data/logs/kubernetes/kube-kubelet /data/kubelet
chmod +x /opt/kubernetes/server/bin/kubelet.sh
创建supervisord文件
vi /etc/supervisord.d/kube-kubelet.ini
[program:kube-kubelet-17-53]
command=/opt/kubernetes/server/bin/kubelet.sh ; the program (relative uses PATH, can take args)
numprocs=1 ; number of processes copies to start (def 1)
directory=/opt/kubernetes/server/bin ; directory to cwd to before exec (def no cwd)
autostart=true ; start at supervisord start (default: true)
autorestart=true ; retstart at unexpected quit (default: true)
startsecs=30 ; number of secs prog must stay running (def. 1)
startretries=3 ; max # of serial start failures (default 3)
exitcodes=0,2 ; ‘expected‘ exit codes for process (default 0,2)
stopsignal=QUIT ; signal used to kill process (default TERM)
stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
user=root ; setuid to this UNIX account to run the program
redirect_stderr=true ; redirect proc stderr to stdout (default false)
stdout_logfile=/data/logs/kubernetes/kube-kubelet/kubelet.stdout.log ; stderr log path, NONE for none; default AUTO
stdout_logfile_maxbytes=64MB ; max # logfile bytes b4 rotation (default 50MB)
stdout_logfile_backups=4 ; # of stdout logfile backups (default 10)
stdout_capture_maxbytes=1MB ; number of bytes in ‘capturemode‘ (default 0)
stdout_events_enabled=false ; emit events on stdout writes (default false)
启动
supervisorctl update
supervisorctl status
检查
kubectl get nodes
给nodes加标签
kubectl label node k8s3.host.com node-role.kubernetes.io/master=
kubectl label node k8s3.host.com node-role.kubernetes.io/node=
kubectl label node k8s4.host.com node-role.kubernetes.io/master=
kubectl label node k8s4.host.com node-role.kubernetes.io/node=
标签:roc tst cts status none ocs domain fail account
原文地址:https://www.cnblogs.com/wq111/p/14087013.html