Kind 安装 kubernets集群

Kind 安装 kubernets

介绍

kind is a tool for running local Kubernetes clusters using Docker container “nodes”.

Kind 是一个通过使用 docker 容器模拟节点来创建本地 k8s 集群的工具。

repo:https://github.com/kubernetes-sigs/kind

website:https://kind.sigs.k8s.io/

快速开始

安装 Docker

因为 Kind 使用 docker 来模拟 kubernetes 集群,启动容器,因此首先需要安装 docker

Docker: https://docs.docker.com/get-docker/

Docker 换源

vim /etc/docker/deamo.json

# 写入以下内容
{
    "registry-mirrors" : [
    "https://registry.docker-cn.com",
    "http://hub-mirror.c.163.com",
    "https://docker.mirrors.ustc.edu.cn",
    "https://cr.console.aliyun.com",
    "https://mirror.ccs.tencentyun.com"
  ]
}

# 重启 docker
systemctl restart docker

安装 Kind

curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.12.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/

如果下载失败,也可以手动下载之后上传到 linux 服务器中。

安装 Kubectl

https://kubernetes.io/zh-cn/docs/tasks/tools/install-kubectl-linux/

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

# 校验 (可跳过)
curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
echo "$(cat kubectl.sha256)  kubectl" | sha256sum --check
# 通过校验: kubectl: OK

# 安装
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

# 查看版本信息
kubectl version --client
kubectl version --client --output=yaml

创建

  1. create 一个 kubernetes 集群

    kind create cluster --name sca-k8s-cluster
    
  2. 检测集群的健康状态

    kubectl cluster-info --context kind-sca-k8s-cluster
    

    输出以下结果则表示创建成功。

    root@yuluo-machine:~# kubectl cluster-info --context kind-sca-k8s-cluster
    Kubernetes control plane is running at https://127.0.0.1:44623
    CoreDNS is running at https://127.0.0.1:44623/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
    
    To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
    root@yuluo-machine:~# kubectl get pod -A
    NAMESPACE            NAME                                                    READY   STATUS    RESTARTS   AGE
    kube-system          coredns-5d78c9869d-vpphj                                1/1     Running   0          11m
    kube-system          coredns-5d78c9869d-zpmhj                                1/1     Running   0          11m
    kube-system          etcd-sca-k8s-cluster-control-plane                      1/1     Running   0          11m
    kube-system          kindnet-lmdnv                                           1/1     Running   0          11m
    kube-system          kube-apiserver-sca-k8s-cluster-control-plane            1/1     Running   0          11m
    kube-system          kube-controller-manager-sca-k8s-cluster-control-plane   1/1     Running   0          11m
    kube-system          kube-proxy-sc879                                        1/1     Running   0          11m
    kube-system          kube-scheduler-sca-k8s-cluster-control-plane            1/1     Running   0          11m
    local-path-storage   local-path-provisioner-6bc4bddd6b-p9rjn                 1/1     Running   0          11m
    

你可能感兴趣的:(云原生,java,study,cloud,native,kind,云原生)