K8S dashboard服务(五)

1.下载dashboard镜像

docker pull docker.io/siriuszg/kubernetes-dashboard-amd64


image.png

2.修改镜像标签,并上传到本地仓库

docker tag docker.io/siriuszg/kubernetes-dashboard-amd64:latest 10.199.150.95:5000/kubernetes-dashboard-amd64
docker push 10.199.150.95:5000/kubernetes-dashboard-amd64

3.创建dashborad的deployment和service

创建deployment

vi dashboard.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
# Keep the name in sync with image version and
# gce/coreos/kube-manifests/addons/dashboard counterparts
  name: kubernetes-dashboard-latest
  namespace: kube-system
spec:
  replicas: 1
  template:
    metadata:
      labels:
        k8s-app: kubernetes-dashboard
        version: latest
        kubernetes.io/cluster-service: "true"
    spec:
      containers:
      - name: kubernetes-dashboard
        image: 10.199.150.95:5000/kubernetes-dashboard-amd64:latest
        resources:
          # keep request = limit to keep this container in guaranteed class
          limits:
            cpu: 100m
            memory: 50Mi
          requests:
            cpu: 100m
            memory: 50Mi
        ports:
        - containerPort: 9090
        args:
         -  --apiserver-host=http://10.199.150.95:8080
        livenessProbe:
          httpGet:
            path: /
            port: 9090
          initialDelaySeconds: 30
          timeoutSeconds: 30

创建service

vi dashboard-svc.yaml
apiVersion: v1
kind: Service
metadata:
  name: kubernetes-dashboard
  namespace: kube-system
  labels:
    k8s-app: kubernetes-dashboard
    kubernetes.io/cluster-service: "true"
spec:
  selector:
    k8s-app: kubernetes-dashboard
  ports:
  - port: 80
    targetPort: 9090

4.创建资源

当前目录下执行
kubectl create -f .


image.png

5.检查资源

由于在service中使用的namespace是kube-system,直接使用kubectl get pod/deployment查看出来的资源是属于namespace的,所以使用如下方法查看
kubectl get svc --namespace=kube-system 需要增加--namespace参数


image.png

6.访问dashboard

访问:http://10.199.150.95:8080/ui/

你可能感兴趣的:(K8S dashboard服务(五))