Enable Kubernetes
From Docker Preferences, enable Kubernetes.
Check to see if it is running by issuing the following command:
> kubectl get nodes
Code Block |
---|
NAME STATUS ROLES AGE VERSION docker-for-desktop Ready master 5h v1.10.3 |
Install the Dashboard
> kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml
Verify that it is installed:
> kubectl get pods --all-namespaces -o wide
Code Block |
---|
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE docker compose-74649b4db6-zpb5t 1/1 Running 0 5h 10.1.0.3 docker-for-desktop docker compose-api-8477889868-jfzph 1/1 Running 0 5h 192.168.65.3 docker-for-desktop kube-system etcd-docker-for-desktop 1/1 Running 0 5h 192.168.65.3 docker-for-desktop kube-system kube-apiserver-docker-for-desktop 1/1 Running 0 5h 192.168.65.3 docker-for-desktop kube-system kube-controller-manager-docker-for-desktop 1/1 Running 0 5h 192.168.65.3 docker-for-desktop kube-system kube-dns-86f4d74b45-txr8w 3/3 Running 0 5h 10.1.0.2 docker-for-desktop kube-system kube-proxy-q5vrd 1/1 Running 0 5h 192.168.65.3 docker-for-desktop kube-system kube-scheduler-docker-for-desktop 1/1 Running 0 5h 192.168.65.3 docker-for-desktop kube-system kubernetes-XXX 1/1 Running 0 50s 10.1.0.4 docker-for-desktop |
Create a user:
vi dashboard-adminuser.yaml
Code Block |
---|
apiVersion: v1 kind: ServiceAccount metadata: name: admin-user namespace: kube-system --- 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: kube-system |
> kubectl apply -f dashboard-adminuser.yaml
Code Block |
---|
serviceaccount/admin-user created clusterrolebinding.rbac.authorization.k8s.io/admin-user created |
Get the Token for the created user
> kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')
Code Block |
---|
Name: admin-user-token-shqsn Namespace: kube-system Labels: <none> Annotations: kubernetes.io/service-account.name: admin-user kubernetes.io/service-account.uid: 8ab8e997-1069-11e9-9ec0-025000000001 Type: kubernetes.io/service-account-token Data ==== token: eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLXNocXNuIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiI4YWI4ZTk5Ny0xMDY5LTExZTktOWVjMC0wMjUwMDAwMDAwMDEiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06YWRtaW4tdXNlciJ9.MejrO_QQmPOg-ga5wXatkBBsTD5NbT0GHyIdxK5Ki3L4Yt1ZjTB8cCmhC2cN7kpus6RXN8fZpeB72UohSd1JBOJbJ9QFobSfEXXgKWD9r366hkuqP3lObTUexNDTsVlx12WUD6Vp_QAkq8ItIQ3o6xdeA2udhrAB8E55vPhK2PzyuaLHkkT-87CmG1amdn9mpZGv4FNHUvS7TYHvHs2ShisWZgLsC9hF8t_TngGWcUA5OXqH_5CzdLAYj3f2qXwXmbYiwrHT9T8PL3gchDDDuvhDxjesWqdWRjKYDU1mJ5oNskEiBQcRF0mOwl5BlZm8VwNAV1CUdKKXeSeI7_cZ6g ca.crt: 1025 bytes namespace: 11 bytes |
Create port forwarding for the dashboard
> kubectl port-forward kubernetes-dashboard-XXX 8443:8443 --namespace=kube-system
Start the proxy
> kubectl proxy
Code Block |
---|
Starting to serve on 127.0.0.1:8001 |
Open your browser
Navigate to:
Sign in using the token previously retrieved.
References
Reference | URL |
---|---|
Docker - Deploy on Kubernetes | https://docs.docker.com/docker-for-mac/kubernetes/ |
Kubernetes Dashboard | https://github.com/kubernetes/dashboard |
Getting Started with Kubernetes with Docker on Mac | https://rominirani.com/tutorial-getting-started-with-kubernetes-with-docker-on-mac-7f58467203fd |