Windows play kubernetes series 4 – build k8s dashboard

Time:2020-11-12

Download official yaml file

The latest configuration file v2.0.0-beta8 recommended.yaml , UI address

wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta8/aio/deploy/recommended.yaml

Original document:

kind: Service
apiVersion: v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kubernetes-dashboard
spec:
  ports:
    - port: 443
      targetPort: 8443
  selector:
    k8s-app: kubernetes-dashboard

It is amended as follows:

kind: Service
apiVersion: v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kubernetes-dashboard
spec:
  Type: nodeport
  ports:
    - port: 443
      Nodeport: 30001 NEW
      targetPort: 8443
  selector:
    k8s-app: kubernetes-dashboard

Contents of the original document

spec:
  containers:
    - name: kubernetes-dashboard
      image: kubernetesui/dashboard:v2.0.0-beta8
      imagePullPolicy: Always
      ports:
        - containerPort: 8443
          protocol: TCP

It is amended as follows:

spec:
  # nodeName:  master.node  Specify to master node, which means not to specify on demand
  containers:
    - name: kubernetes-dashboard
      image: kubernetesui/dashboard:v2.0.0-beta8
      # imagePullPolicy: Always
      Imagepullpolicy: ifnotpresent ා does not exist to download
      ports:
        - containerPort: 8443
          protocol: TCP

Download Image and boot

It is executed in the master node

docker pull kubernetesui/dashboard:v2.0.0-beta8

implement

kubectl apply -f recommended.yaml

Windows play kubernetes series 4 - build k8s dashboard

View pod and service status

kubectl get pods,svc -n kubernetes-dashboard -o wide
kubectl describe po kubernetes-dashboard --namespace=kubernetes-dashboard

Windows play kubernetes series 4 - build k8s dashboard

If you find out

kubernetes-dashboard crashloopbackoff

kubectl get pods --all-namespaces
systemctl stop kubelet
systemctl stop docker
iptables --flush
iptables -tnat --flush
systemctl start kubelet
systemctl start docker
kubectl delete -f recommended.yaml

List all nodes: kubectl get node
Delete node: kubectl delete node node3
View the pods information on the corresponding node: kubectl get Pods – O wide | grep node3

Rejoin
Execute: kubeadm reset on the server corresponding to the deleted node3

iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -F
iptables -L -n
mkdir cert

cd cert/

openssl genrsa -out dashboard.key 2048
openssl req -days 36000   -new -out dashboard.csr    -key dashboard.key   -subj '/CN=**192.168.56.106**'


openssl x509 -req -in dashboard.csr -signkey dashboard.key -out dashboard.crt

kubectl create secret generic kubernetes-dashboard-certs     --from-file=dashboard.key     --from-file=dashboard.crt      -n kubernetes-dashboard

Windows play kubernetes series 4 - build k8s dashboard

New create- admin.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

function

 kubectl apply -f create-admin.yaml

See SA and secret

kubectl get sa,secrets -n kubernetes-dashboard
kubectl describe secret admin-user-token-t79xh -n kubernetes-dashboard

Windows play kubernetes series 4 - build k8s dashboard

Get token login success:
Windows play kubernetes series 4 - build k8s dashboard

Recommended Today

Implementation example of go operation etcd

etcdIt is an open-source, distributed key value pair data storage system, which provides shared configuration, service registration and discovery. This paper mainly introduces the installation and use of etcd. Etcdetcd introduction etcdIt is an open source and highly available distributed key value storage system developed with go language, which can be used to configure sharing […]