Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # install
- kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml
- # jalankan perintah berikut, pastikan pod running
- kubectl get pods -A
- # Creating Admin user
- mkdir ~/dashboard && cd ~/dashboard
- nano dashboard-admin.yaml
- # isi yaml
- apiVersion: v1
- kind: ServiceAccount
- metadata:
- name: admin-user
- namespace: kubernetes-dashboard
- ---
- 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
- # lanjut ketik
- kubectl apply -f dashboard-admin.yaml
- # Get the admin token using the command below.
- kubectl get secret -n kubernetes-dashboard $(kubectl get serviceaccount admin-user -n kubernetes-dashboard -o jsonpath="{.secrets[0].name}") -o jsonpath="{.data.token}" | base64 --decode
- # jalankan perintah berikut jika menggunakan proxy
- kubectl proxy
- # akses di browser
- http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
- # jika mau dijadikan nodeport agar bisa diakses dari luar, buat file yaml service
- kind: Service
- apiVersion: v1
- metadata:
- labels:
- k8s-app: kubernetes-dashboard
- name: kubernetes-dashboard
- namespace: kubernetes-dashboard
- spec:
- ports:
- - port: 443
- targetPort: 8443
- nodePort: 30069
- selector:
- k8s-app: kubernetes-dashboard
- type: NodePort
- # kemudian apply
- kubectl apply -f nodeportdashboard.yaml
- # membuat token user read only
- nano dashboard-read-only.yaml
- # isi yaml
- apiVersion: v1
- kind: ServiceAccount
- metadata:
- name: read-only-user
- namespace: kubernetes-dashboard
- ---
- apiVersion: rbac.authorization.k8s.io/v1
- kind: ClusterRole
- metadata:
- annotations:
- rbac.authorization.kubernetes.io/autoupdate: "true"
- labels:
- name: read-only-clusterrole
- namespace: default
- rules:
- - apiGroups:
- - ""
- resources: ["*"]
- verbs:
- - get
- - list
- - watch
- - apiGroups:
- - extensions
- resources: ["*"]
- verbs:
- - get
- - list
- - watch
- - apiGroups:
- - apps
- resources: ["*"]
- verbs:
- - get
- - list
- - watch
- ---
- apiVersion: rbac.authorization.k8s.io/v1
- kind: ClusterRoleBinding
- metadata:
- name: read-only-binding
- roleRef:
- kind: ClusterRole
- name: read-only-clusterrole
- apiGroup: rbac.authorization.k8s.io
- subjects:
- - kind: ServiceAccount
- name: read-only-user
- namespace: kubernetes-dashboard
- # kemudian apply
- kubectl apply -f dashboard-read-only.yaml
- # get token read only
- kubectl get secret -n kubernetes-dashboard $(kubectl get serviceaccount read-only-user -n kubernetes-dashboard -o jsonpath="{.secrets[0].name}") -o jsonpath="{.data.token}" | base64 --decode
- # agar dashboard bisa diakses dari pc lain, tidak dari localhost saja, forward dengan tambahan --address 0.0.0.0
- kubectl -n kubernetes-dashboard port-forward --address 0.0.0.0 $POD_NAME 8443:8443 &
Add Comment
Please, Sign In to add comment