使用 kind 集群安装运行极狐GitLab Runner【上】

GitLab 是一个全球知名的一体化 DevOps 平台,很多人都通过私有化部署 GitLab 来进行源代码托管。极狐GitLab 是 GitLab 在中国的发行版,专门为中国程序员服务。可以一键式部署极狐GitLab。

关于 kind

kind 是一个用来运行本地 Kubernetes 机群的工具,主要使用 Docker 容器来做为 “nodes”。kind 的主要设计目的是为了测试 Kubernetes 本身,但是也可以在本地研发或者运行 CI 的时候使用 kind。

kind is a tool for running local Kubernetes clusters using Docker container “nodes”. kind was primarily designed for testing Kubernetes itself, but may be used for local development or CI.

kind 的安装

kind 的安装非常方便,根据不同的 OS 安装即可:

Linux 安装:

# For AMD64 / x86_64
[ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.22.0/kind-linux-amd64
# For ARM64
[ $(uname -m) = aarch64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.22.0/kind-linux-arm64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind

macOS 安装:

# For Intel Macs
[ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.22.0/kind-darwin-amd64
# For M1 / ARM Macs
[ $(uname -m) = arm64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.22.0/kind-darwin-arm64
chmod +x ./kind
mv ./kind /some-dir-in-your-PATH/kind

Windows 安装:

$ curl.exe -Lo kind-windows-amd64.exe https://kind.sigs.k8s.io/dl/v0.22.0/kind-windows-amd64
Move-Item .\kind-windows-amd64.exe c:\some-dir-in-your-PATH\kind.exe

本文以 macOS 安装为例,直接使用 brew 安装:

$ brew install kind

安装完毕,可以使用 version 或者 help 命令进行查看:

$ kind --version
kind version 0.17.0

$ kind --help
kind creates and manages local Kubernetes clusters using Docker container 'nodes'

Usage:
  kind [command]

Available Commands:
  build       Build one of [node-image]
  completion  Output shell completion code for the specified shell (bash, zsh or fish)
  create      Creates one of [cluster]
  delete      Deletes one of [cluster]
  export      Exports one of [kubeconfig, logs]
  get         Gets one of [clusters, nodes, kubeconfig]
  help        Help about any command
  load        Loads images into nodes
  version     Prints the kind CLI version

Flags:
  -h, --help              help for kind
      --loglevel string   DEPRECATED: see -v instead
  -q, --quiet             silence all stderr output
  -v, --verbosity int32   info log verbosity, higher value produces more output
      --version           version for kind

Use "kind [command] --help" for more information about a command.

kind 的使用

可以使用 kind 创建一个本地 kubernetes 集群:

$ kind create cluster --name jh-gitlab
Creating cluster "jh-gitlab" ...
 ✓ Ensuring node image (kindest/node:v1.25.3) 
 ✓ Preparing nodes 
 ✓ Writing configuration 
 ✓ Starting control-plane ️
 ✓ Installing CNI 
 ✓ Installing StorageClass 
Set kubectl context to "kind-jh-gitlab"
You can now use your cluster with:

kubectl cluster-info --context kind-jh-gitlab

Thanks for using kind! 

查看创建好的集群:

$ kind get clusters
jh-gitlab
kind

切换到想要测试的集群:

$ kubectl cluster-info --context kind-jh-gitlab
Kubernetes control plane is running at https://127.0.0.1:61452
CoreDNS is running at https://127.0.0.1:61452/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

查看集群的 node、ns 等:

$ kubectl get ns
NAME                 STATUS   AGE
default              Active   42h
kube-node-lease      Active   42h
kube-public          Active   42h
kube-system          Active   42h
local-path-storage   Active   42h

$ kubectl get nodes
NAME                      STATUS   ROLES           AGE   VERSION
jh-gitlab-control-plane   Ready    control-plane   42h   v1.25.3

现在 kubernetes 集群安装成功,接下来就可以使用此集群安装极狐GitLab Runner 了。可以参考下篇文章。

更多关于极狐GitLab 的最佳实践,可以搜索关注公众号【极狐GitLab】或者登录极狐GitLab 官网进行学习。

你可能感兴趣的:(kind,gitlab,云原生,runner)