Mac系统kubernetes安装笔记

  • Post author:
  • Post category:其他


1、kubernetes dashboard apply报错

Mac终端执行命令: kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.2.0/aio/deploy/recommended.yaml报

The connection to the server raw.githubusercontent.com was refused – did you specify the right host or port?

在这里插入图片描述

解决方案:

1)查询raw.githubusercontent.com域名IP

https://ip.tool.chinaz.com/raw.githubusercontent.com查询raw.githubusercontent.com

在这里插入图片描述

2)hosts文件(/etc/hosts)中新增域名ip映射

185.199.108.133 raw.githubusercontent.com

185.199.109.133 raw.githubusercontent.com

185.199.110.133 raw.githubusercontent.com

185.199.111.133 raw.githubusercontent.com

3)重新执行kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.2.0/aio/deploy/recommended.yaml

在这里插入图片描述

4)终端输入kubectl proxy启动服务,默认提示如下:Starting to serve on 127.0.0.1:8001

在这里插入图片描述

5)浏览器地址栏访问kubernetes-dashboard 验证(默认端口8001)

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/pod?namespace=default出现如下说明kubernetes-dashboard部署成功

在这里插入图片描述

参考官方文档:https://github.com/kubernetes/dashboard/

2、mysql语句后需要带上分号;

未带分号如下:

在这里插入图片描述

带分号:

在这里插入图片描述

3、kubectl apply -f config.yaml报错

Error from server (BadRequest): error when creating “config.yaml”: ConfigMap in version “v1” cannot be handled as a ConfigMap: v1.ConfigMap.Data: ReadString: expects ” or n, but found 1, error found in #10 byte of …|ASSWORD”:123456,“ACC|…, bigger context …|sion”:“v1”,“data”:{“ACCOUNT_DATASOURCE_PASSWORD”:123456,“ACCOUNT_DATASOURCE_URL”:”jdbc:mysql://mysql|…

解决方案:

提示少了”引号,经检查config.yaml发现密码如果是数值类型需要加上引号

在这里插入图片描述

改成”123456″后重新执行提示configmap/common-config created说明执行成功,即

在这里插入图片描述

登录kubernetes-dashboard 中Config Maps即可查看加载到配置信息

4、kubectl -n kubernetes-dashboard get secret $(kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath=”{.secrets[0].name}”) -o go-template=”{

{.data.token | base64decode}}”

报错Error from server (NotFound): serviceaccounts “admin-user” not found

Error executing template: template: output:1:16: executing “output” at : wrong number of args for base64decode: want 1 got 0. Printing more information for debugging the template:

在这里插入图片描述

1)cat <<EOF | kubectl apply -f –

apiVersion: v1

kind: ServiceAccount

metadata:

name: admin-user

namespace: kubernetes-dashboard

EOF

在这里插入图片描述

2)

cat <<EOF | kubectl apply -f –

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

    EOF

    在这里插入图片描述

    输入:kubectl -n kubernetes-dashboard get secret $(kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath=”{.secrets[0].name}”) -o go-template=”{

    {.data.token | base64decode}}”

    出现类似如同token,token有效期失效后,过期后需重新生成

    在这里插入图片描述



版权声明:本文为hjs218原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。