Kubernetesの起動順序や読み込む環境定義ファイル

#1 環境

```
[root@master1 ~]# cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)

```


#2 現在のランレベル

```
[root@master1 ~]# systemctl get-default
multi-user.target

```


#3 k8s,etcd,Dockerのユニット定義ファイルの格納場所(/usr/lib/systemd/system配下)

```
[root@master1 ~]# ls -la /etc/systemd/system/multi-user.target.wants|grep -e kube -e etcd -e docker
lrwxrwxrwx. 1 root root   38 11月  9 20:13 docker.service -> /usr/lib/systemd/system/docker.service
lrwxrwxrwx. 1 root root   36 11月 14 20:07 etcd.service -> /usr/lib/systemd/system/etcd.service
lrwxrwxrwx. 1 root root   46 11月 16 20:11 kube-apiserver.service -> /usr/lib/systemd/system/kube-apiserver.service
lrwxrwxrwx. 1 root root   55 11月 18 20:01 kube-controller-manager.service -> /usr/lib/systemd/system/kube-controller-manager.service
lrwxrwxrwx. 1 root root   42 11月 18 20:01 kube-proxy.service -> /usr/lib/systemd/system/kube-proxy.service
lrwxrwxrwx. 1 root root   46 11月 18 20:01 kube-scheduler.service -> /usr/lib/systemd/system/kube-scheduler.service
lrwxrwxrwx. 1 root root   39 11月 16 20:11 kubelet.service -> /usr/lib/systemd/system/kubelet.service
[root@master1 ~]#

```


#4 起動順序


```

[Unit]
Description=Docker Storage Setup
After=cloud-init.service
Before=docker.service

[Unit]
Description=Docker Application Container Engine
After=network.target rhel-push-plugin.socket
Wants=docker-storage-setup.service

[Unit]
Description=Etcd Server
After=network.target
After=network-online.target
Wants=network-online.target

[Unit]
Description=Kubernetes API Server
After=network.target
After=etcd.service

[Unit]
Description=Kubernetes Kube-Proxy Server
After=network.target

[Unit]
Description=Kubernetes Kubelet Server
After=docker.service
Requires=docker.service

[Unit]
Description=Kubernetes Controller Manager

[Unit]
Description=Kubernetes Scheduler Plugin

```



#5 起動時に読み込む環境変数


| サービス名                     | 読み込む環境変数定義ファイル(EnvironmentFile定義)  |備考                                         |
|:------------------------------|:------------------------------------------------|:--------------------------------------------|
|docker-storage-setup.service   |/etc/sysconfig/docker-storage-setup              |                                             |
|docker.service                 |/etc/sysconfig/docker                            |環境変数として GOTRACEBACK=crash を読み込む    |
|                               |/etc/sysconfig/docker-storage                    |                                             |
|                               |/etc/sysconfig/docker-network                    |                                             |
|etcd.service                   |/etc/etcd/etcd.conf                              |                                             |
|kube-apiserver.service         |/etc/kubernetes/config                           |k8s関連のサービスは共通の                      |
|                               |/etc/kubernetes/apiserver                        |定義ファイル(config)を読み込んだあと            |
|kube-proxy.service             |/etc/kubernetes/config                           |個別の定義ファイルを読み込む                    |
|                               |/etc/kubernetes/proxy                            |   |
|kubelet.service                |/etc/kubernetes/config                           |   |
|                               |/etc/kubernetes/proxy                            |   |
|kube-controller-manager.service|/etc/kubernetes/config                           |   |
|                               |/etc/kubernetes/proxy                            |   |
|kube-scheduler.service         |/etc/kubernetes/config                           |   |
|                               |/etc/kubernetes/proxy                            |   |

#6 参考情報
http://acchi-muite-hoi.hatenablog.com/entry/2016/05/18/171240