CentOS7 minimal で kubernetes ~ part 1~
github.com
に書かれていることをほぼなぞっただけだけど。
VirtualBoxのインストール
割愛。あとで書くかも。
CentOS7 minimal のインストール
master用とminion用に2つ作成
詳細は割愛。あとで書くかも。
ipアドレスの設定
master = 192.168.1.17 minion-1 = 192.168.1.18
CentOSの設定
最新にアップデート(master,minion)
# yum update -y
リポジトリの追加(master,minion)
# vi /etc/yum.repos.d/\_virt7-testing.repo [virt7-testing] name=virt7-testing baseurl=http://cbs.centos.org/repos/virt7-testing/x86_64/os/ gpgcheck=0
kubernetesのインストール(master, minion)
# yum -y install --enablerepo=virt7-testing kubernetes
etcdのインストール(master)
kubernetesを動かすにはetcd-0.4.6-7が必要。
# systemctl restart etcd # curl -s -L http://master:4001/version
やってるときには確認方法がわからなかったので、マニュアルに従う。
# yum erase etcd # yum install http://cbs.centos.org/kojifiles/packages/etcd/0.4.6/7.el7.centos/x86_64/etcd-0.4.6-7.el7.centos.x86_64.rpm # yum -y install --enablerepo=virt7-testing kubernetes
/etc/hostsの設定(master, minion)
echo "192.168.1.17 master 192.168.1.18 minion-1" >> /etc/hosts
/etc/kubernetes/config の設定(master, minion)
### # kubernetes system config # # The following values are used to configure various aspects of all # kubernetes services, including # # kube-apiserver.service # kube-controller-manager.service # kube-scheduler.service # kubelet.service # kube-proxy.service # logging to stderr means we get it in the systemd journal KUBE_LOGTOSTDERR="--logtostderr=true" # journal message level, 0 is debug KUBE_LOG_LEVEL="--v=0" # Should this cluster be allowed to run privileged docker containers KUBE_ALLOW_PRIV="--allow_privileged=false" # Comma separated list of nodes in the etcd cluster KUBE_ETCD_SERVERS="--etcd-servers=http://master:4001"
firewall の無効化(master, minion)
systemctl disable iptables-services firewalld
systemctl stop iptables-services firewalld
Kubernetes Service の設定(master)
/etc/kubernetes/apiserver の設定(master)
### # kubernetes system config # # The following values are used to configure the kube-apiserver # # The address on the local server to listen to. # KUBE_API_ADDRESS="--address=127.0.0.1" KUBE_API_ADDRESS="--address=0.0.0.0" # The port on the local server to listen on. KUBE_API_PORT="--port=8080" # How the replication controller and scheduler find the kube-apiserver KUBE_MASTER="--master=http://master:8080" # Comma separated list of minions KUBELET_ADDRESSES="--machines=minion-1" # Port minions listen on KUBELET_PORT="--kubelet_port=10250" # Address range to use for services KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16" # default admission control policies # KUBE_ADMISSION_CONTROL="--admission_control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota" # Add your own! KUBE_API_ARGS=""
service 起動(master)
# for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do systemctl restart $SERVICES systemctl enable $SERVICES systemctl status $SERVICES done
Kubernetes Service の設定(minion)
/etc/kubernetes/kubeletの設定(minion)
### # kubernetes kubelet (minion) config # The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces) KUBELET_ADDRESS="--address=0.0.0.0" # The port for the info server to serve on KUBELET_PORT="--port=10250" # You may leave this blank to use the actual hostname KUBELET_HOSTNAME="--hostname_override=minion-1" # location of the api-server KUBELET_API_SERVER="--api_servers=http://master:8080" # Add your own! KUBELET_ARGS=""
/etc/kubernetes/proxy の設定(minion)
マニュアルには書かれていないけれど、kube-proxyこの設定をしないとkube-proxy起動時にエラーログが出力された。*1
### # kubernetes proxy config # default config should be adequate # Add your own! # KUBE_PROXY_ARGS="" KUBE_PROXY_ARGS="--master=http://master:8080"
service 起動(minion)
for SERVICES in kube-proxy kubelet docker; do systemctl restart $SERVICES systemctl enable $SERVICES systemctl status $SERVICES done
完成!
clusterの確認(master)
# kubectl get nodes NAME LABELS STATUS minion-1 kubernetes.io/hostname=minion-1 Ready
次はpodを動かすよ。
*1:kube-proxy[732]: E0814 07:53:48.793584 732 api.go:180] Unable to load endpoints: Get http://localhost:8080/api/v1/endpoints: dial tcp 127.0.0.1:8080: connection refused kube-proxy[732]: E0814 07:53:48.793631 732 api.go:108] Unable to load services: Get http://localhost:8080/api/v1/services: dial tcp 127.0.0.1:8080: connection refused