SaltStack Kubernetes Module Setting

Installation

  • Kubernetes API를 호출하는데 사용할 Target Minion에 아래와 같이 Package를 설치합니다.

  • root 권한에서 작업합니다.

kubernetes 설치

  • Kubernetes API Python Bindings

Kubernetes API Python 버전은 12.0.1 로 지정하여 Install 해야 함.

다른 버전 설치 시 오류가 발생할 수 있음.

$ pip3 install kubernetes==12.0.1

Configuring K8s KUBERNETESMOD

salt-minion config에 추가할 내용은 다음과 같다.
아래 中, kubernetes.kubeconfigkubernetes.kubeconfig-data 둘 중 하나만 설정하면 된다.
만일 둘 다 설정되어 있다면, kubernetes.kubeconfig를 우선한다.

단, kubernetes.kubeconfig로 설정하였을 경우는, k8s Control plane node에 salt-minion설치 및 설정되어야 하는 경우만 해당된다.(로컬 파일에 접근해야 하기 때문)

원격 노드에서 k8s api를 사용해야 하는 경우kubernetes.kubeconfig-data를 사용하도록 한다.

위의 이유로 CH에서는 kubernetes.kubeconfig-data를 사용하는 방법을 표준으로 채택한다.

kubernetes.kubeconfig: '/root/.kube/config' kubernetes.kubeconfig-data: '<base64 encoded "/root/.kube/config" content>' kubernetes.context: '<context name inside ~/.kube/config>'

kubernetes.kubeconfig-data 설정 방법은 다음과 같다.

먼저 kubeconfig 파일 내용을 base64one line encoding한다.

$ cat ~/.kube/config | base64 | tr -d '\n' YfasdreXBpVmVyc2lvbjogdjEKY2x1c3RlcnM6Ci0gY2x1c3RlcjoKICAgIGNlcnRpZmljYXRlLWF1dGhvcml0eS1kYXRhOiBMUzB0TFMxQ1JVZEpUaUJEUlZKVVNVWkpRMEZVUlMwdExTMHRDazFKU1VONVJFTkRRV0pEWjBGM1NVSkJaMGxDUVVSQlRrSm5hM0ZvYTJsSE9YY3dRa0ZSYzBaQlJFRldUVkpOZDBWUldVUldVVkZFUlhkd2NtUlhTbXdLWTIwMWJHUkhWbnBOUWpSWVJGUkpkMDFFWTNsUFZFRXdUVVJaTVUweGIxaEVWRTEzVFVSamVVNTZRVEJOUkZreFRURnZkMFpVUlZSTlFrV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Fo0TXpkVGRHbE9NemhuU2pZeFYzRkhNVFIzV2dwSU1UUXdTMWszVm1WVFlWaEtSbmhzUmxsNmQzbzNNMjV3SzIxalJUSk1NRkZDTTNweVFsTjFiWFpFVVhwaGVXbHNWV00yWVZwbGVXNHhNMjVUTjI5TkNreHFZazVCYjBkQlprMWhkSGRVWlZoTGNtZFdXWHBsVldONFdIUXhhRE4wVFRkTGVFMVZWU3RWTlc5dlVYVmphRTlqTUhoaVRYRXdXRE5YVFRoR1IwY0tTbXN3V1ZvdlVFNXVSa1JhVFV4emIxSndVbVZXUlVONU5uZENiRWRCU2tWbVNIRm9XbUl4YVRkbmRFNTZXbFF2YzBrMVNXZzNZa2R5UzFCTmFGSkVlUXB0UlhWYU4wOXBOVVUxSzJabE1UbExOMEpoTTNjeFJUSjJWRVl6U20xd1QxVkJlVkpLTVRZck1FNDJhMjV2UkRKa2RqZzlDaTB0TFMwdFJVNUVJRkpUUVNCUVVrbFdRVlJGSUV0RldTMHRMUzB0Q2c9PQo=

minion.conf파일에 다음과 같이 추가한다.

Testing Salt command

 CloudHub Portal addon argument 추가

  • Sidebar의 Clouds 메뉴에서 Kubernetes Tab을  on/off optionable 처리합니다.

  • CloudHub argument에 Add-on 옵션 추가합니다.

    • -u=k8s:on

  • CloudHub service 재시작