(十七)、Mac 安装k8s (直接使用 Docker Desktop)

最佳实践

本文的方式其实不太好管理,建议使用 minikube 本级单集群的方式,借助 VS Code 获得更好的体验

使用 minikube 运行k8s 集群
从宿主机访问 k8s(minikube) 发布的 redis 服务

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 c
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值