k8s ui 安装各种采坑,Dashboard 是k8s的插件,安装k8s要安装image和一个kubernetes-dashboard.yaml文件。

把拉取的镜像安装在了docker下,docker创建进行

docker search Kubernetes-dashboard

安装下载量对多的,

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

安装完成后打标签,存放到私有库

docker tag docker.io/mritd/kubernetes-dashboard-amd64:latest 192.168.101.135:5000/kubernetes-dashboard-amd64

 push 上传到私有仓库

docker push 192.168.101.135:5000/kubernetes-dashboard-amd64:latest

创建namespace

vi kube-namespace.yaml

piVersion: v1
kind: Namespace
metadata:
  name: kube-system

 编写yaml文件

vi  k8s.yaml

kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  labels:
    app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kube-system
spec:
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: kubernetes-dashboard
  template:
    metadata:
      labels:
        app: kubernetes-dashboard
      # Comment the following annotation if Dashboard must not be deployed on master
      annotations:
        scheduler.alpha.kubernetes.io/tolerations: |
          [
            {
              "key": "dedicated",
              "operator": "Equal",
              "value": "master",
              "effect": "NoSchedule"
            }
          ]
    spec:
      containers:
      - name: kubernetes-dashboard
        image: 192.168.101.135:5000/kubernetes-dashboard-amd64
        imagePullPolicy: Always
        ports:
        - containerPort: 9090
          protocol: TCP
        args:
          # Uncomment the following line to manually specify Kubernetes API server Host
          # If not specified, Dashboard will attempt to auto discover the API server and connect
          # to it. Uncomment only if the default does not work.
          # - --apiserver-host=http://my-address:port
          - --apiserver-host=http://192.168.101.134:8080
        livenessProbe:
          httpGet:
            path: /
            port: 9090
          initialDelaySeconds: 30
          timeoutSeconds: 30
---
kind: Service
apiVersion: v1
metadata:
  labels:
    app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kube-system
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 9090
  selector:
    app: kubernetes-dashboard

创建pod和service
kubectl create -f  k8s.yaml

然后查看pod

kubectl get pods --all-namespaces

在浏览器里访问 http://IP:8080/ui

安装过程中遇到的问题:

执行了命名查看到的错误

kubectl describe pods/kubernetes-dashboard-3773930492-54h8n  --namespace="kube-system"

Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull failed for registry.access.redhat.com/rhel7/pod-infrastructure:latest, this may be because there are no credentials on this request.  details: (open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such file or directory)"

解决方法:

执行了yum install *rhsm* -y 后还有没解决

接下来有执行了

wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm

rpm -ivh python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm

如果执行报错,执行

yum remove subscription-manager-rhsm-certificates -y

安装完后在节点服务器node上手动执行

docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest

删除rc重新安装

kubectl delete -f k8s.yaml

在创建

kubectl create -f k8s.yaml

Logo

开源、云原生的融合云平台

更多推荐