使用 Docker Desktop 时,请确保您已进行推荐的设置。
创建一个名为 kind-cluster-config.yaml
的文件,并粘贴以下内容:
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 8081
protocol: TCP
- containerPort: 443
hostPort: 8443
protocol: TCP
- role: worker
- role: worker
此集群配置:
运行 kind create cluster
命令,提供集群配置文件:
kind create cluster --config kind-cluster-config.yaml
预期输出
Creating cluster "kind" ...
✓ Ensuring node image (kindest/node:v1.21.1) 🖼
✓ Preparing nodes 📦 📦 📦
✓ Writing configuration 📜
✓ Starting control-plane 🕹️
✓ Installing CNI 🔌
✓ Installing StorageClass 💾
✓ Joining worker nodes 🚜
Set kubectl context to "kind-kind"
You can now use your cluster with:
kubectl cluster-info --context kind-kind
Thanks for using kind! 😊
在 Kubernetes 中初始化 Dapr。
dapr init --kubernetes
Dapr 初始化完成后,您可以在集群上使用其核心组件。
验证 Dapr 组件的状态:
dapr status -k
预期输出
NAME NAMESPACE HEALTHY STATUS REPLICAS VERSION AGE CREATED
dapr-sentry dapr-system True Running 1 1.5.1 53s 2021-12-10 09:27.17
dapr-operator dapr-system True Running 1 1.5.1 53s 2021-12-10 09:27.17
dapr-sidecar-injector dapr-system True Running 1 1.5.1 53s 2021-12-10 09:27.17
dapr-dashboard dapr-system True Running 1 0.9.0 53s 2021-12-10 09:27.17
dapr-placement-server dapr-system True Running 1 1.5.1 52s 2021-12-10 09:27.18
将端口转发到 Dapr 仪表板:
dapr dashboard -k -p 9999
访问 http://localhost:9999
检查设置是否成功。
获取 metrics-server 清单
wget https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
向 components.yaml 文件添加不安全的 TLS 参数
metadata:
labels:
k8s-app: metrics-server
spec:
containers:
- args:
- --cert-dir=/tmp
- --secure-port=4443
- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
- --kubelet-use-node-status-port
- --kubelet-insecure-tls <==== 添加此项
- --metric-resolution=15s
image: k8s.gcr.io/metrics-server/metrics-server:v0.6.2
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
httpGet:
path: /livez
应用修改后的清单
kubectl apply -f components.yaml