(十七)、Mac 安装k8s

news2024/11/18 15:33:51

文章目录

    • 1、Enable Kubernetes
    • 2、查看k8s运行状态
    • 3、启用 kubernetes-dashboard
      • 3.1、如果启动成功,可以在浏览器访问
      • 3.2、如果没有跳转,需要单独安装 kubernetes-dashboard
        • 3.2.1、方式一:一步到位
        • 3.2.2、方式二:逐步进行

1、Enable Kubernetes

Mac 安装了 Docker 和 Docker Desktop
然后在 settings 勾选 Enable Kubernetes
在这里插入图片描述

然后可以看到下面,说明安装成功
在这里插入图片描述

2、查看k8s运行状态

kubectl cluster-info

# 打印信息
Kubernetes control plane is running at https://127.0.0.1:6443
CoreDNS is running at https://127.0.0.1:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

3、启用 kubernetes-dashboard

用于直观查看 k8s 的运行状态

kubectl proxy

3.1、如果启动成功,可以在浏览器访问

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

在这里插入图片描述

3.2、如果没有跳转,需要单独安装 kubernetes-dashboard

先确认状态,正常的话会有两个运行状态

➜  ~ kubectl get pods -n kubernetes-dashboard


NAME                                         READY   STATUS    RESTARTS   AGE
dashboard-metrics-scraper-748b4f5b9d-gn5x8   1/1     Running   0          3h51m
kubernetes-dashboard-86b687bd84-9m5lv        1/1     Running   0          3h51m
3.2.1、方式一:一步到位

网络不好会遇到域名无法解析问题

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.5.1/aio/deploy/recommended.yaml
3.2.2、方式二:逐步进行

先把 https://raw.githubusercontent.com/kubernetes/dashboard/v2.5.1/aio/deploy/recommended.yaml 内容保存到本地,比如存储为文件 aaa.txt

# Copyright 2017 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: Namespace
metadata:
  name: kubernetes-dashboard

---

apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kubernetes-dashboard

---

kind: Service
apiVersion: v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kubernetes-dashboard
spec:
  ports:
    - port: 443
      targetPort: 8443
  selector:
    k8s-app: kubernetes-dashboard

---

apiVersion: v1
kind: Secret
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard-certs
  namespace: kubernetes-dashboard
type: Opaque

---

apiVersion: v1
kind: Secret
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard-csrf
  namespace: kubernetes-dashboard
type: Opaque
data:
  csrf: ""

---

apiVersion: v1
kind: Secret
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard-key-holder
  namespace: kubernetes-dashboard
type: Opaque

---

kind: ConfigMap
apiVersion: v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard-settings
  namespace: kubernetes-dashboard

---

kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kubernetes-dashboard
rules:
  # Allow Dashboard to get, update and delete Dashboard exclusive secrets.
  - apiGroups: [""]
    resources: ["secrets"]
    resourceNames: ["kubernetes-dashboard-key-holder", "kubernetes-dashboard-certs", "kubernetes-dashboard-csrf"]
    verbs: ["get", "update", "delete"]
    # Allow Dashboard to get and update 'kubernetes-dashboard-settings' config map.
  - apiGroups: [""]
    resources: ["configmaps"]
    resourceNames: ["kubernetes-dashboard-settings"]
    verbs: ["get", "update"]
    # Allow Dashboard to get metrics.
  - apiGroups: [""]
    resources: ["services"]
    resourceNames: ["heapster", "dashboard-metrics-scraper"]
    verbs: ["proxy"]
  - apiGroups: [""]
    resources: ["services/proxy"]
    resourceNames: ["heapster", "http:heapster:", "https:heapster:", "dashboard-metrics-scraper", "http:dashboard-metrics-scraper"]
    verbs: ["get"]

---

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
rules:
  # Allow Metrics Scraper to get metrics from the Metrics server
  - apiGroups: ["metrics.k8s.io"]
    resources: ["pods", "nodes"]
    verbs: ["get", "list", "watch"]

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kubernetes-dashboard
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: kubernetes-dashboard
subjects:
  - kind: ServiceAccount
    name: kubernetes-dashboard
    namespace: kubernetes-dashboard

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: kubernetes-dashboard
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: kubernetes-dashboard
subjects:
  - kind: ServiceAccount
    name: kubernetes-dashboard
    namespace: kubernetes-dashboard

---

kind: Deployment
apiVersion: apps/v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kubernetes-dashboard
spec:
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      k8s-app: kubernetes-dashboard
  template:
    metadata:
      labels:
        k8s-app: kubernetes-dashboard
    spec:
      securityContext:
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: kubernetes-dashboard
          image: kubernetesui/dashboard:v2.5.1
          imagePullPolicy: Always
          ports:
            - containerPort: 8443
              protocol: TCP
          args:
            - --auto-generate-certificates
            - --namespace=kubernetes-dashboard
            # 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
          volumeMounts:
            - name: kubernetes-dashboard-certs
              mountPath: /certs
              # Create on-disk volume to store exec logs
            - mountPath: /tmp
              name: tmp-volume
          livenessProbe:
            httpGet:
              scheme: HTTPS
              path: /
              port: 8443
            initialDelaySeconds: 30
            timeoutSeconds: 30
          securityContext:
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            runAsUser: 1001
            runAsGroup: 2001
      volumes:
        - name: kubernetes-dashboard-certs
          secret:
            secretName: kubernetes-dashboard-certs
        - name: tmp-volume
          emptyDir: {}
      serviceAccountName: kubernetes-dashboard
      nodeSelector:
        "kubernetes.io/os": linux
      # Comment the following tolerations if Dashboard must not be deployed on master
      tolerations:
        - key: node-role.kubernetes.io/master
          effect: NoSchedule

---

kind: Service
apiVersion: v1
metadata:
  labels:
    k8s-app: dashboard-metrics-scraper
  name: dashboard-metrics-scraper
  namespace: kubernetes-dashboard
spec:
  ports:
    - port: 8000
      targetPort: 8000
  selector:
    k8s-app: dashboard-metrics-scraper

---

kind: Deployment
apiVersion: apps/v1
metadata:
  labels:
    k8s-app: dashboard-metrics-scraper
  name: dashboard-metrics-scraper
  namespace: kubernetes-dashboard
spec:
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      k8s-app: dashboard-metrics-scraper
  template:
    metadata:
      labels:
        k8s-app: dashboard-metrics-scraper
    spec:
      securityContext:
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: dashboard-metrics-scraper
          image: kubernetesui/metrics-scraper:v1.0.7
          ports:
            - containerPort: 8000
              protocol: TCP
          livenessProbe:
            httpGet:
              scheme: HTTP
              path: /
              port: 8000
            initialDelaySeconds: 30
            timeoutSeconds: 30
          volumeMounts:
          - mountPath: /tmp
            name: tmp-volume
          securityContext:
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            runAsUser: 1001
            runAsGroup: 2001
      serviceAccountName: kubernetes-dashboard
      nodeSelector:
        "kubernetes.io/os": linux
      # Comment the following tolerations if Dashboard must not be deployed on master
      tolerations:
        - key: node-role.kubernetes.io/master
          effect: NoSchedule
      volumes:
        - name: tmp-volume
          emptyDir: {}
          

然后 手动运行

kubectl apply -f aaa.txt

#预期会打印
namespace/kubernetes-dashboard created
serviceaccount/kubernetes-dashboard created
service/kubernetes-dashboard created
secret/kubernetes-dashboard-certs created
secret/kubernetes-dashboard-csrf created
secret/kubernetes-dashboard-key-holder created
configmap/kubernetes-dashboard-settings created
role.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard created
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
deployment.apps/kubernetes-dashboard created
service/dashboard-metrics-scraper created
deployment.apps/dashboard-metrics-scraper created

此时可能会

➜  ~ kubectl get pods -n kubernetes-dashboard
NAME                                         READY   STATUS             RESTARTS   AGE
dashboard-metrics-scraper-748b4f5b9d-gn5x8   1/1     Running            0          7m45s
kubernetes-dashboard-86b687bd84-9m5lv        0/1     ImagePullBackOff   0  

然后手动下载

docker pull kubernetesui/dashboard:v2.5.1
此时正常
➜  ~ kubectl get pods -n kubernetes-dashboard
NAME                                         READY   STATUS    RESTARTS   AGE
dashboard-metrics-scraper-748b4f5b9d-gn5x8   1/1     Running   0          15m
kubernetes-dashboard-86b687bd84-9m5lv        1/1     Running   0          15m

最后再次访问
http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/ 出现页面即可

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2175386.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

杭州网站设计中的常见误区及解决方案

在杭州网站设计领域,随着数字经济的快速发展,越来越多的企业意识到互联网的重要性。然而,在实际的网站设计过程中,仍然存在一些常见的误区,这些误区可能会影响用户体验和网站的整体效果。以下是几种普遍存在的误区及其…

国产动漫论坛系统小程序的设计

管理员账户功能包括:系统首页,个人中心,用户管理,动漫分类管理,动漫视频管理,动漫图片管理,动漫文章管理,交流论坛,系统管理 微信端账号功能包括:系统首页&a…

汇编语言 访问CMOS RAM并打印时间(未完)

题目:以"年/月/日 时:分:秒"的格式,显示当前的日期,时间 提示:在此代码的基础上加以改造 assume cs:code code segment start:mov al,9 ;年out 70h,al ;传入9号单元的地址in al,71h ;取9号单元的内容,高4位为十位、低4位为各位mov ah,almov cl,4shr ah,…

1-仙灵之谜(区块链游戏详情介绍)

1-仙灵之谜(区块链游戏详情介绍) 前言(该游戏仅供娱乐)正文 前言(该游戏仅供娱乐) 依稀记得本科那会儿参加了一个区块链实验室,那时每周末大家都会爬山或者抽出一下午讨论区块链以及未来&#x…

< 初等物理 >

SI国际单位制 常见的公制单位 为什么需要单位,是统一衡量的标准 通过国际单位,以及单位的拓展,以及单位的组合,形成一系列新的测量单位 面积 m^2 速率 m/s 米每二次方秒,m / s, delta表示增量, 每秒移动多少米 加…

pdf怎么转变成jpg图片?值得推荐的几种PDF转jpg方法

pdf怎么转变成jpg图片?jpg格式的图像在电子邮件、社交媒体等在线平台上分享非常方便,用户无需担心软件兼容性问题。将PDF内容转换为jpg后,能够有效保留原始文档的视觉布局,使信息更加生动易懂,适合用于演示和展示。同时…

【小沐学GIS】基于ubuntu+three.js的OSM建筑模型显示(node.js、Python)

文章目录 1、简介1.1 ubuntu1.2 node1.3 python1.4 osm1.5 three.js 2、安装ubuntu3、安装node4、安装python结语 1、简介 1.1 ubuntu https://cn.ubuntu.com/download https://ubuntu.com/download Ubuntu是一个以桌面应用为主的Linux发行版操作系统,其名称来自非…

萝卜大杂烩 | 快速掌控seaborn(画图必备)

本文来源公众号“萝卜大杂烩”,仅用于学术分享,侵权删,干货满满。 原文链接:快速掌控seaborn Matplotlib绘制一张美图需要很多参数调整,于是就出现了high-level版的Seaborn,几行代码即可输出美美的图形&am…

超详细的 GitHub 个人主页美化教程

Guthub 个人主页 (官方称呼是 profile)可以展示很多有用的信息,例如添加一个首页被访问次数的计数器,一个被 Star 与 Commit 的概览信息,以及各种技能标签,设备标签等,还可以利用 wakatime 显示…

一文上手SpringSecurity【七】

之前我们在测试的时候,都是使用的字符串充当用户名称和密码,本篇将其换成MySQL数据库. 一、替换为真实的MySQL 1.1 引入依赖 <dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.33</v…

一文理解mysql 联合索引和各种SQL语句分析

文章目录 索引图示主键索引二级索引表SQL总结索引图示 主键索引 二级索引 这里如果是联合索引的话,那里面的key就是多个colume的值 表 -- demo.`order` definitionCREATE TABLE `order` (

请求转发和响应重定位

一、请求转发 二、响应重定位 302&#xff1a;服务器的收到请求&#xff0c;但所需要的行为和资源要重定位到其他地方&#xff08;可以是外部和服务器的其他位置&#xff09;时就会像请求者发送302状态码 location响应头&#xff1a;告诉请求者重定位的URL路径

【前端】35道JavaScript进阶问题(1)

来源&#xff1a; javascript-questions/zh-CN/README-zh_CN.md at master lydiahallie/javascript-questions GitHub 记录一些有趣的题。 1 输出是&#xff1f; const shape {radius: 10,diameter() {return this.radius * 2},perimeter: () > 2 * Math.PI * this.rad…

如何通过python+sqlalchemy获得MSsql视图的结构

话不多说 目的:为了对接第三方表视图,需要知道表视图的字段结构,如名称,对应的表字段类型 实现结果如图: 直接上代码: from sqlalchemy import create_engine, MetaData, select, text from web import urlquoteDRIVER "ODBC Driver 18 for SQL Server" INSTANCE…

晓羽知识答题系统V1.8.0

一款适用于企业或组织进行知识答题系统&#xff0c;根据排名进行奖品派发&#xff0c;支持微信小程序和H5方式使用 V1.8.0答题活动支持按题型分配问题数量 答题活动支持按题型分配问题数量&#xff0c;满足指定一定数量的单选题、多选题、判断题&#xff1b; 答题活动支持注…

【数据结构】环形队列(循环队列)学习笔记总结

文章目录 什么是环形队列?基于 C 语言实现环形队列环形队列的应用场合 在计算机科学中&#xff0c;数据结构是组织和存储数据的方式&#xff0c;它对于高效的算法设计至关重要。队列是一种常见的数据结构&#xff0c;遵循 FIFO&#xff08;先进先出&#xff0c;First-In-Firs…

【AIGC】ChatGPT提示词助力自媒体内容创作升级

博客主页&#xff1a; [小ᶻZ࿆] 本文专栏: AIGC | ChatGPT 文章目录 &#x1f4af;前言&#x1f4af;高效仿写专家级文章提示词使用方法 &#x1f4af;CSDN博主账号分析提示词使用方法 &#x1f4af;自媒体爆款文案优化助手提示词使用方法 &#x1f4af;小结 &#x1f4af…

外贸网站怎么搭建对谷歌seo比较好?

外贸网站怎么搭建对谷歌seo比较好&#xff1f;搭建一个网站自然不复杂&#xff0c;但要想搭建一个符合谷歌seo规范的网站&#xff0c;那就要多注意了&#xff0c;你的网站做的再酷炫&#xff0c;再花里胡哨&#xff0c;但如果页面都是js代码&#xff0c;或者页面没有源代码内容…

解决Windows远程桌面 “为安全考虑,已锁定该用户账户,原因是登录尝试或密码更改尝试过多,请稍后片刻再重试,或与系统管理员或技术支持联系“问题

根本原因就是当前主机被通过远程桌面输入了过多的错误密码&#xff0c;被系统锁定。这种情况多数是你的服务器远程桌面被人试图攻击了&#xff0c;不建议取消系统锁定策略。如果阿里云或者腾讯云主机&#xff0c;只需要在管理后台通过管理终端或者VNC登陆一次&#xff0c;锁定即…

友元运算符重载函数

目录 1.定义友元运算符重载函数的语法形式 2.双目运算符重载 3.单目运算符重载 1.定义友元运算符重载函数的语法形式 &#xff08;1&#xff09;在类的内部&#xff0c;定义友元运算符重载函数的格式如下&#xff1a; friend 函数类型 operator 运算符&#xff08;形参表&a…