Master服务
安装kubernetes
1 | tar -xvf kubernetes.tar.gz -C /opt/ |
下载 Client Binaries,Server Binaries
1 | uname -s -m #获取版本官网下载或执行下面命令下载 |
Kubernetes release: v1.11.0
Server: linux/amd64 (to override, set KUBERNETES_SERVER_ARCH)
Client: linux/amd64 (autodetected)
Will download kubernetes-server-linux-amd64.tar.gz from https://dl.k8s.io/v1.11.0
Will download and extract kubernetes-client-linux-amd64.tar.gz from https://dl.k8s.io/v1.11.0
Is this ok? [Y]/n
kubernetes-server
1 | tar -tf kubernetes-server-linux-amd64.tar.gz #查看文件 |
kubernetes-client
1 | tar -tf kubernetes-client-linux-amd64.tar.gz |
执行文件(配置文件可以直接路径)
1 | sudo ln -s /opt/kubernetes/server/bin/kube-apiserver /usr/bin/ |
准备依赖服务 etcd
etcd releases下载 如果s3.amazonaws.com下不动。。。
被墙了 被墙了 被墙了
go 编译
1 | #mkdir -p $GOPATH/src/go.etcd.io/ |
can’t load package: package go.etcd.io/etcd: cannot find package “go.etcd.io/etcd” in any of:
/opt/go/src/go.etcd.io/etcd (from $GOROOT)
/home/cs/gopath/src/go.etcd.io/etcd (from $GOPATH)
1 | $GOPATH/bin/etcd #运行 |
创建用户
1 | sudo groupadd -g 995 etcd |
etcd.service
1 | [Unit] |
sudo systemctl start etcd.service
该命令启动不了 /bin/bash -c “GOMAXPROCS=$(nproc) /usr/bin/etcd –name=\”${ETCD_NAME}\” –data-dir=\”${ETCD_DATA_DIR}\” –listen-client-urls=\”${ETCD_LISTEN_CLIENT_URLS}\””
sudo systemctl status etcd.service
**bash[9841]: run the stateless etcd v3 gRPC L7 reverse proxy
debian systemd[1]: etcd.service: main process exited, code=exited, status=2/INVALIDARGUMENT
debian systemd[1]: Failed to start Etcd Server.
**
设置etcd
ExecStart=/opt/etcd-v3.3.9/etcd
启动etcd服务
1 | temp="etcd.service" |
● etcd.service - Etcd Server
Loaded: loaded (/lib/systemd/system/etcd.service; enabled)
Active: active (running) since 六 2018-09-08 14:53:26 CST; 5min ago
Main PID: 804 (etcd)CGroup: /system.slice/etcd.service
└─804 /opt/etcd-v3.3.9/etcd
1 | ./etcdctl cluster-health |
member 8e9e05c52164694d is healthy: got healthy result from http://localhost:2379
cluster is healthy
kube-apiserver
创建用户
1 | sudo groupadd -g 996 kube |
kube-apiserver.service
1 | [Unit] |
1.error creating self-signed certificates: mkdir /var/run/kubernetes: permission denied
2.error: –etcd-servers must be specified
配置
1 | sudo cat>/etc/kubernetes/apiserver<<EOF |
–etcd-servers:就是etcd的地址。
–insecure-bind-address:apiserver绑定主机的非安全IP地址,设置0.0.0.0表示绑定所有IP地址。
–insecure-port:apiserver绑定主机的非安全端口,默认为8080。
–service-cluster-ip-range:Kubernetes集群中Service的虚拟IP地址段范围,以CIDR格式表示,该IP范围不能与物理机真实IP段有重合。
-service-node-port-range:Kubernetes集群中Service可映射的物理机端口范围,默认为30000~32767.
–admission-control: Kubernetes集群的准入控制设置,各控制模块以插件形式依次生效。
–logtostderr:设置为false表示将日志写入文件,不写入stderr。
–log-dir: 日志目录。
–v:日志级别。
启动
1 | temp="kube-apiserver.service" |
● kube-apiserver.service - Kubernetes API Server
Loaded: loaded (/lib/systemd/system/kube-apiserver.service; disabled)
Active: active (running) since 六 2018-09-08 15:42:02 CST; 2s ago
Docs: https://github.com/GoogleCloudPlatform/kubernetesMain PID: 3560 (kube-apiserver)
CGroup: /system.slice/kube-apiserver.service
└─3560 /opt/kubernetes/server/bin/kube-apiserver –etcd-servers=http://localhost:2379 …….
kube-controller-manager
kube-controller-manager.service
1 | [Unit] |
配置
1 | sudo touch /etc/kubernetes/controller-manager && sudo chmod 757 /etc/kubernetes/controller-manager |
启动
1 | temp="kube-controller-manager.service" |
● kube-controller-manager.service - Kubernetes Scheduler Plugin
Loaded: loaded (/lib/systemd/system/kube-controller-manager.service; disabled)
Active: active (running) since 六 2018-09-08 16:54:32 CST; 2s ago
Docs: https://github.com/GoogleCloudPlatform/kubernetes
Main PID: 5980 (kube-controller)
CGroup: /system.slice/kube-controller-manager.service
└─5980 /opt/kubernetes/server/bin/kube-controller-manager –master=http://localhost:8080 ……
kube-scheduler
kube-scheduler.service
1 | [Unit] |
配置
1 | sudo touch /etc/kubernetes/scheduler && sudo chmod 757 /etc/kubernetes/scheduler |
启动
1 | temp="kube-scheduler.service" |
● kube-scheduler.service - Kubernetes Scheduler Manager
Loaded: loaded (/lib/systemd/system/kube-scheduler.service; disabled)
Active: active (running) since 六 2018-09-08 17:02:09 CST; 7s ago
Docs: https://github.com/kubernetes
Main PID: 6340 (kube-scheduler)CGroup: /system.slice/kube-scheduler.service
└─6340 /opt/kubernetes/server/bin/kube-scheduler –master=http://localhost:8080 ……
Node节点服务
kubelet
kubelet.service
1 | [Unit] |
kubelet.service holdoff time over, scheduling restart
配置
1 | sudo mkdir -p /var/lib/kubelet |
–require-kubeconfig 1.7版开始默认true
Kubernetes 1.8开始要求关闭系统的Swap
启动
1 | temp="kubelet.service" |
● kubelet.service - Kubernetes Kubelet Server
Loaded: loaded (/lib/systemd/system/kubelet.service; disabled)
Active: active (running) since 二 2018-09-11 18:34:48 CST; 29ms ago
Docs: https://github.com/kubernetes
Main PID: 9018 (kubelet)CGroup: /system.slice/kubelet.service
└─9018 /opt/kubernetes/server/bin/kubelet –kubeconfig=/etc/kubernetes/kubeconfig –hostname-override=127.0.0.1 –logtostderr=false –log-dir=/var/log/kubernetes –v=2 –cgroup-driver=systemd
kube-proxy
kube-proxy.service
1 | [Unit] |
配置
1 | sudo touch /etc/kubernetes/proxy && sudo chmod 757 /etc/kubernetes/proxy |
启动
1 | temp="kube-proxy.service" |