文章目录
最佳实践
本文的方式其实不太好管理,建议使用 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、如果启动成功,可以在浏览器访问
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