MacOS에 Kubernetes를 설치하고, 실습하는 내용을 적었습니다.
위의 사진처럼, Docker를 실행시킨후, Preference에 접속합니다.
Enable Kubernetes
와 Show system containers (advanced)
를 체크해주고, Apply & Restart를 눌러줍니다.
Popup이 뜨고, Instsall을 클릭하면, 사진의 왼쪽 하단과 같이 Kubernetes running
표시가 나타납니다.
$ curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl"
$ chmod +x ./kubectl
$ sudo mv ./kubectl /usr/local/bin/kubectl
$ kubectl version --client
Install kubectl on macOS에 자세한 설명이 나와 있습니다.
위의 명령어들은 공식 문서에 적혀있는 명령어들을 나열한 것입니다.
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml
$ kubectl proxy
위 두 명령어를 통해 Local에서 Kubernetes Dashboard에 접근할 수 있습니다.
접속Url: http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
$ cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kubernetes-dashboard
EOF
$ cat <<EOF | kubectl apply -f -
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kubernetes-dashboard
EOF
$ kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}')
Name: admin-user-token-j6vbh
Namespace: kubernetes-dashboard
Labels: <none>
Annotations: kubernetes.io/service-account.name: admin-user
kubernetes.io/service-account.uid: a60fb691-9218-4021-aa1f-5e2cff8b442c
Type: kubernetes.io/service-account-token
Data
====
ca.crt: 1025 bytes
namespace: 20 bytes
token: eyJhbGciOiJSUzI1NiIsImtpZCI6IjFFZEdUUkN2OEd4elVaZmFhY3FnS2RVS1lYWlpVNzRDS1pHTHpWTEc1TjAifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLWo2dmJoIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJhNjBmYjY5MS05MjE4LTQwMjEtYWExZi01ZTJjZmY4YjQ0MmMiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZXJuZXRlcy1kYXNoYm9hcmQ6YWRtaW4tdXNlciJ9.K8WRwl_pphQVDU_3CtlBRdtwBPFLCdF7DOFSpZiS634PJGlmPDlOzaW8mSIHYSAKgrC8aHZswk0jjbdzlUHz-TVsLxw_i3iSk-2a3mUFrFaT2MR8wSnIFSybZGI_qgZJlvWZ_pIPB9o04UIT5sBOrxA9BEqJdcwoLYD81oeHgjzZrkmWNM9h71ko4a27eLooubuYygDNJGeRvddnJ8_ZIt32h57jwpJzTcPcUV71MsVm3y2xfYCKMckqHvmINJyvfnyDS0OgumjxUWx4hvZ0yMHmNpN_u-l8XHezWnXq8UWyXK2rQdAXmJwgDYhq3IngmIBv6wwphhhWypknAqJihA
Dashboard에 접속하기 위해선 Sample user를 만들어 Token을 발급 받아야 합니다.
공식 문서의 명령어들을 순차적으로 실행하면 마지막에 token을 발급받습니다.
위에서 복사한 token을 토큰 입력에 붙여 넣습니다.
그럼, 아래와 같이 Kubernetes dashboard에 접속할 수 있게됩니다.