本地安装K8S方式 方式一 minikube 方式二 kin

注意 安装后占用本机资源较少,适合学习测试使用,不建议用于生产

前提条件

方式一 minikube

minikube 安装指南
启动

1
bash复制代码minikube start

集群中安装 ingress:

1
bash复制代码minikube addons enable ingress

方式二 kind (Kubernets in docker)

kind 安装指南
Then spins up a kind cluster:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
bash复制代码cat <<EOF | kind create cluster --image=kindest/node:v1.18.15 --config=-
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: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
EOF

安装 ingress:

1
bash复制代码kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/kind/deploy.yaml

安装结果

我使用mac系统,使用方式二 通过kind安装

检查安装k8s健康状态

1
bash复制代码kubectl get cs

查看结果

1
2
3
4
bash复制代码NAME                 STATUS      MESSAGE                                                                                     ERROR
scheduler Unhealthy Get http://127.0.0.1:10251/healthz: dial tcp 127.0.0.1:10251: connect: connection refused
controller-manager Unhealthy Get http://127.0.0.1:10252/healthz: dial tcp 127.0.0.1:10252: connect: connection refused
etcd-0 Healthy {"health":"true"}

本文转载自: 掘金

开发者博客 – 和开发相关的 这里全都有

0%