----------------------------------------------------------------------------------------------------------------------------
执行主机:192.168.1.15and16and18
创建etcd二进制服务文件
注:需要改的字段为
--name=etcd01
--initial-advertise-peer-urls=https://192.168.1.16:2380 \
--listen-peer-urls=https://192.168.1.16:2380 \
--listen-client-urls=https://192.168.1.16:2379,http://127.0.0.1:2379 \
--advertise-client-urls=https://192.168.1.16:2379 \
cat >/root/kubernetes/server/bin/etcd-service/etcd.service <<'HERE'
[Unit]
Description=Etcd Server
After=network.target
After=network-online.target
Wants=network-online.target
Documentation=https://github.com/coreos
[Service]
Type=notify
WorkingDirectory=/var/lib/etcd/
EnvironmentFile=-/etc/etcd/etcd.conf
ExecStart=/usr/local/bin/etcd \
--name=etcd01 \
--cert-file=/etc/kubernetes/ssl/kubernetes.pem \
--key-file=/etc/kubernetes/ssl/kubernetes-key.pem \
--peer-cert-file=/etc/kubernetes/ssl/kubernetes.pem \
--peer-key-file=/etc/kubernetes/ssl/kubernetes-key.pem \
--trusted-ca-file=/etc/kubernetes/ssl/k8s-root-ca.pem \
--peer-trusted-ca-file=/etc/kubernetes/ssl/k8s-root-ca.pem \
--initial-advertise-peer-urls=https://192.168.1.18:2380 \
--listen-peer-urls=https://192.168.1.18:2380 \
--listen-client-urls=https://192.168.18:2379,http://127.0.0.1:2379 \
--advertise-client-urls=https://192.168.1.18:2379 \
--initial-cluster-token=etcd-cluster-0 \
--initial-cluster=etcd01=https://192.168.1.15:2380,etcd02=https://192.168.1.16:2380,etcd03=https://192.168.1.18:2380 \
--initial-cluster-state=new \
--data-dir=/var/lib/etcd
Restart=on-failure
RestartSec=5
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
HERE
----------------------------------------------------------------------------------------------------------------------------
执行主机:192.168.1.15and16and18
创建kube-apiserver二进制服务文件
cat >/root/kubernetes/server/bin/master-service/kube-apiserver.service <<'HERE'
[Unit]
Description=Kubernetes API Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=network.target
[Service]
ExecStart=/usr/local/bin/kube-apiserver \
--admission-control=NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,ResourceQuota,NodeRestriction \
--advertise-address=192.168.1.15 \
--bind-address=192.168.1.15 \
--insecure-bind-address=192.168.1.15 \
--kubelet-https=true \
--runtime-config=rbac.authorization.k8s.io/v1beta1 \
--authorization-mode=RBAC,Node \
--enable-bootstrap-token-auth \
--token-auth-file=/etc/kubernetes/ssl/token.csv \
--service-cluster-ip-range=10.254.0.0/16 \
--service-node-port-range=300-9000 \
--tls-cert-file=/etc/kubernetes/ssl/kubernetes.pem \
--tls-private-key-file=/etc/kubernetes/ssl/kubernetes-key.pem \
--client-ca-file=/etc/kubernetes/ssl/k8s-root-ca.pem \
--service-account-key-file=/etc/kubernetes/ssl/k8s-root-ca-key.pem \
--etcd-cafile=/etc/kubernetes/ssl/k8s-root-ca.pem \
--etcd-certfile=/etc/kubernetes/ssl/kubernetes.pem \
--etcd-keyfile=/etc/kubernetes/ssl/kubernetes-key.pem \
--etcd-servers=https://192.168.1.15:2379,https://192.168.1.16:2379,https://192.168.1.18:2379 \
--enable-swagger-ui=true \
--allow-privileged=true \
--apiserver-count=3 \
--audit-log-maxage=30 \
--audit-log-maxbackup=3 \
--audit-log-maxsize=100 \
--audit-log-path=/var/lib/audit.log \
--event-ttl=1h \
--v=2
Restart=on-failure
RestartSec=5
Type=notify
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
HERE
----------------------------------------------------------------------------------------------------------------------------
执行主机:192.168.1.15and16and18
创建kube-scheduler二进制服务文件
cat >/root/kubernetes/server/bin/master-service/kube-scheduler.service <<'HERE'
[Unit]
Description=Kubernetes Scheduler
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
[Service]
ExecStart=/usr/local/bin/kube-scheduler \
--address=192.168.1.15 \
--master=http://192.168.1.15:8080 \
--leader-elect=true \
--v=2
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
HERE
----------------------------------------------------------------------------------------------------------------------------
执行主机:192.168.1.15and16and18
创建kube-controller-manager二进制服务文件
cat >/root/kubernetes/server/bin/master-service/kube-controller-manager.service <<'HERE'
[Unit]
Description=Kubernetes Controller Manager
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
[Service]
ExecStart=/usr/local/bin/kube-controller-manager \
--address=192.168.1.15 \
--master=http://192.168.1.15:8080 \
--allocate-node-cidrs=true \
--service-cluster-ip-range=10.254.0.0/16 \
--cluster-cidr=172.16.0.0/16 \
--cluster-name=kubernetes \
--cluster-signing-cert-file=/etc/kubernetes/ssl/k8s-root-ca.pem \
--cluster-signing-key-file=/etc/kubernetes/ssl/k8s-root-ca-key.pem \
--service-account-private-key-file=/etc/kubernetes/ssl/k8s-root-ca-key.pem \
--root-ca-file=/etc/kubernetes/ssl/k8s-root-ca.pem \
--leader-elect=true \
--v=2
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
HERE
----------------------------------------------------------------------------------------------------------------------------
执行主机:192.168.1.15and16and18
创建kubelet二进制服务文件
cat >/root/kubernetes/server/bin/node-service/kubelet.service <<'HERE'
[Unit]
Description=Kubernetes Kubelet
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=docker.service
Requires=docker.service
[Service]
WorkingDirectory=/var/lib/kubelet
ExecStart=/usr/local/bin/kubelet \
--address=192.168.1.15 \
--hostname-override=k8s-master-1 \
--pod-infra-container-image=gcr.io/google_containers/pause-amd64:3.0 \
--experimental-bootstrap-kubeconfig=/etc/kubernetes/ssl/bootstrap.kubeconfig \
--kubeconfig=/etc/kubernetes/ssl/kubelet.kubeconfig \
--cert-dir=/etc/kubernetes/ssl \
--hairpin-mode promiscuous-bridge \
--allow-privileged=true \
--serialize-image-pulls=false \
--logtostderr=true \
--cgroup-driver=systemd \
--cluster_dns=10.254.0.2 \
--fail-swap-on=false \
--cluster_domain=cluster.local \
--cgroup-driver=systemd \
--runtime-cgroups=/systemd/system.slice \
--kubelet-cgroups=/systemd/system.slice \
--v=2
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
HERE
----------------------------------------------------------------------------------------------------------------------------
执行主机:192.168.1.15and16and18
创建kube-proxy二进制服务文件
cat >/root/kubernetes/server/bin/node-service/kube-proxy.service <<'HERE'
[Unit]
Description=Kubernetes Kube-Proxy Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=network.target
Requires=docker.service
[Service]
ExecStart=/usr/local/bin/kube-proxy \
--logtostderr=true \
--v=2 \
--master=http://192.168.1.15:8080 \
--bind-address=192.168.1.15 \
--hostname-override=192.168.1.15 \
--kubeconfig=/etc/kubernetes/ssl/kube-proxy.kubeconfig \
--cluster-cidr=10.254.0.0/16 \
--proxy-mode=iptables
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
HERE
----------------------------------------------------------------------------------------------------------------------------
执行主机:192.168.1.15and16and18
下发服务文件
rsync -aP /root/kubernetes/server/bin/master-service/ /lib/systemd/system/
rsync -aP /root/kubernetes/server/bin/node-service/ /lib/systemd/system/
rsync -aP /root/kubernetes/server/bin/etcd-service/ /lib/systemd/system/


Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐