其他分享
首页 > 其他分享> > k8s部署dashboard:v1.5.1

k8s部署dashboard:v1.5.1

作者:互联网

1.准备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: registry.cn-beijing.aliyuncs.com/omgasw/kubernetes-dashboard-amd64:v1.5.1
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://192.168.1.201:8080 #修改apiserver地址
livenessProbe:
httpGet:
path: /
port: 9090
initialDelaySeconds: 30
timeoutSeconds: 30

2.准备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

3.在master主机执行创建pod

kubectl create -f dashboard.yaml

kubectl create -f dashboard-svc.yaml

4.验证pod状态,部署完成

[root@master01 ~]# kubectl get deployment -n kube-system
NAME                          DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
kubernetes-dashboard-latest   1         1         1            1           27m
[root@master01 ~]# kubectl get svc -n kube-system -o wide
NAME                   CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE       SELECTOR
kubernetes-dashboard   10.254.110.133   <none>        80/TCP    31m       k8s-app=kubernetes-dashboard
[root@master01 ~]# kubectl get pod  -o wide  --all-namespaces
NAMESPACE     NAME                                           READY     STATUS    RESTARTS   AGE       IP            NODE
kube-system   kubernetes-dashboard-latest-2956427889-5r0m8   1/1       Running   0          32m       172.16.60.2   192.168.1.202

访问http://192.168.1.201:8080/ui  #master主机地址

如果无法访问请参考以下:https://blog.csdn.net/fei79534672/article/details/78710858

iptables -nL    #查看iptables策略
iptables -P FORWARD ACCEPT


转载:https://www.cnblogs.com/omgasw/archive/2019/03/20/10563524.html

标签:kubectl,k8s,kubernetes,yaml,v1.5,dashboard,kube
来源: https://www.cnblogs.com/dwq-good/p/13232314.html