本篇文字包括以下两个部分

  • docker私有仓库搭建
  • kubernetes-dashboard搭建

docker私有仓库搭建

  1. 设置镜像拉取加速器
    DaoCloud提供免费加速器

    私有仓库机器执行如下操作

  2. /etc/pki/tls/openssl.cnf
[ v3_ca ]  
subjectAltName = IP:192.168.169.125
cd /etc/docker
mkdir -p certs && openssl req -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key -x509 -days 365 -out certs/domain.crt

mkdir -p /etc/docker/certs.d/192.168.51.232:5000
cp certs/domain.crt /etc/docker/certs.d/192.168.51.232:5000/ca.crt
systemctl restart docker

docker run -d -p 5000:5000 --restart=always --name registry   -v `pwd`/certs:/certs   -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt   -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key   registry:2

其他node节点执行如下操作

# mkdir -p /etc/docker/certs.d/192.168.51.232:5000
# scp root@192.168.51.232:/etc/docker/certs/domain.crt /etc/docker/certs.d/192.168.169.125:5000/ca.crt
# systemctl restart docker

可以在其他国内的镜像仓库上拉取pause镜像和dashboard镜像
在镜像仓库机器上

docker pull docker.io/kubernetes/pause
docker tag  docker.io/kubernetes/pause 192.168.51.232:5000/pause
docker push  192.168.51.232:5000/pause

将pause镜像上传到私有仓库上

同理dashboard镜像也如此

docker pull daocloud.io/gfkchinanetquest/kubernetes-dashboard-amd64
docker tag daocloud.io/gfkchinanetquest/kubernetes-dashboard-amd64 192.168.51.232:5000/kube-ui:v2
docker push 192.168.51.232:5000/kube-ui:v2

node节点配置修改
/etc/kubernetes/kubelet
这里写图片描述

kubernetes-dashboard搭建

wget http://rawgit.com/kubernetes/dashboard/master/src/deploy/kubernetes-dashboard.yaml

vi kubernetes-dashboard.yaml
    metadata:
      labels:
        app: kubernetes-dashboard
    spec:
      containers:
      - name: kubernetes-dashboard
        image: 192.168.51.232:5000/kube-ui:v3
        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=192.168.51.198: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

只截取了一部分

 image: 192.168.51.232:5000/kube-ui:v3
 - --apiserver-host=192.168.51.198:8080
 kubectl create -f kubernetes-dashboard.yaml  创建
 kubectl delete -f kubernetes-dashboard.yaml  删除

 kubectl get pods --all-namespaces  查看pods
 [root@master scripts]# kubectl get service --all-namespaces
NAMESPACE     NAME                   CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
default       kubernetes             10.254.0.1       <none>        443/TCP        4h
kube-system   kubernetes-dashboard   10.254.146.237   <nodes>       80:31235/TCP   2h

通过describe的命令你可以知道该应用运行在那个节点上,而上面的31235为映射端口;
这里写图片描述

基于此kube-ui已经搭建成功;


参考文献
kubernetes集群搭建
installing-kubernetes-cluster
kubernetes常用命令
kubernetes学习


更新
前两天私有仓库的系统坏了,我就按照上面的步骤再弄了一遍,结果老是报错,改了行的方法

vi /etc/sysconfig/docker
添加
OPTIONS='--insecure-registry 192.168.51.232:5000'

systemctl restart docker
docker pull registry:2
docker run -d -p 5000:5000 -v /home/registry:/tmp/registry --name registry registry:2
curl 192.168.51.232:5000/v2/_catalog

报错
Get https://192.168.51.232:5000/v1/_ping: http: server gave HTTP response to HTTPS client

修改
mv /etc/docker/daemon.json  /etc/docker/daemon.json.bak
vi /etc/docker/daemon.json
加入
{ "insecure-registries":["192.168.51.232:5000"] }

restart重启

然后就神奇的可以了

[参考网站](http://www.jb51.net/article/106803.htm)
GitHub 加速计划 / da / dashboard
14.17 K
4.13 K
下载
General-purpose web UI for Kubernetes clusters
最近提交(Master分支:3 个月前 )
9a476333 Bumps [jest-preset-angular](https://github.com/thymikee/jest-preset-angular) from 14.2.0 to 14.2.2. - [Release notes](https://github.com/thymikee/jest-preset-angular/releases) - [Changelog](https://github.com/thymikee/jest-preset-angular/blob/main/CHANGELOG.md) - [Commits](https://github.com/thymikee/jest-preset-angular/compare/v14.2.0...v14.2.2) --- updated-dependencies: - dependency-name: jest-preset-angular dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 3 个月前
11b7e82e Bumps [cypress](https://github.com/cypress-io/cypress) from 13.13.1 to 13.13.2. - [Release notes](https://github.com/cypress-io/cypress/releases) - [Changelog](https://github.com/cypress-io/cypress/blob/develop/CHANGELOG.md) - [Commits](https://github.com/cypress-io/cypress/compare/v13.13.1...v13.13.2) --- updated-dependencies: - dependency-name: cypress dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 3 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐