Install kubectl and helm client

============================= Install and configure kubectl =========================

Reference: https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl

---------------------------------- A),Install kubectl on CentOS/RHEL via yum --------------------------------------
A1), configure the kubernetes yum repo

vi /etc/yum.repos.d/kubernetes.repo

[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

A2), # yum install -y kubectl
If you got an error like “Peer’s Certificate issuer is not recognized.”
It means you set the wrong certificate, please install kubectl binary using curl/wget.

If step A failed, you can install kubectl as step B, else ignore step B.
---------------------------------- B), Install kubectl binary using curl/wget on Linux ----------------------------------
B1), Download the latest release with the command:

curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl

To download a specific version, replace the $(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) portion of the command with the specific version.
For example, to download version v1.11.0 on Linux, type:

curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.11.0/bin/linux/amd64/kubectl

Or you can use wget to download the binary

wget https://storage.googleapis.com/kubernetes-release/release/v1.11.0/bin/linux/amd64/kubectl

If got an error: “ERROR: cannot verify storage.googleapis.com’s certificate…Unable to locally verify the issuer’s authority.”
To connect to storage.googleapis.com insecurely, use `–no-check-certificate’.

wget https://storage.googleapis.com/kubernetes-release/release/v1.11.0/bin/linux/amd64/kubectl --no-check-certificate

B2), Make the kubectl binary executable.
chmod +x ./kubectl

B3), Move the binary into your PATH.
sudo mv ./kubectl /usr/local/bin/kubectl

---------------------------------- C), Config kubectl ----------------------------------
C), After you install kubectl, add cert and config in ~/.kube/

you can refer Azure VPN account about how to config ~/.kube
then check kubectl configuration with commands

ls ~/.kube/config

kubectl cluster-info

kubectl config view

Reference(Linux/MacOS/Windows): https://docs.aws.amazon.com/zh_cn/eks/latest/userguide/install-kubectl.html#install-kubectl-windows

========================= Install and configure Helm =========================
Prerequsiter:
I), K8S version >= 1.4.1
II), .kube/config is correct.

---------------------------------- A), Install the latest version helm. ----------------------------------
A1), # curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh
A2), # chmod u+x get_helm.sh
A3), # ./get_helm.sh # this script downloads and uncompress archieve
A4), # helm init
A5), # helm list # run a command to check helm installation.
Error: incompatible versions client[v2.10.0] server[v2.9.1]

If approach A failed, you can install specific version helm as below, or please ignore this.

---------------------------------- B), Install specific version helm ----------------------------------
B1), Access to https://github.com/helm/helm/releases and find out the specific version download link for your OS.
e.g. https://storage.googleapis.com/kubernetes-helm/helm-v2.9.1-windows-amd64.zip
B2), # wget https://storage.googleapis.com/kubernetes-helm/helm-v2.9.1-windows-amd64.zip
B3), # tar -zxvf helm-v2.9.1-linux-amd64.tgz && mv linux-amd64/helm /usr/local/bin/helm
B4), # helm init
B5), # helm list # run a command to check helm installation.

Tips: Helm init will connect to kubernetes cluster ( use configuration in ~/.kube/config ) and install Tiller in kube-system namespace to your running Kubernetes cluster. It will also set up any necessary local configuration ( in ~/.helm ).

### 使用 Helm 在 Kubernetes 上安装 PostgreSQL 为了在 Kubernetes 中通过 Helm 安装 PostgreSQL,可以采用 Stolon 这样的高可用解决方案来实现。Stolon 是一个用于 PostgreSQL 的高可用工具,能够很好地集成到 Kubernetes 环境中[^2]。 具体操作命令如下所示: ```bash $ helm install ./stolon --name postgresql --namespace stolon ``` 这条命令将会把名为 `postgresql` 的 Release 发布至命名空间 `stolon` 下面,并且基于本地路径下的 `./stolon` Chart 文件来进行部署。 对于想要简化这一过程的情况,可以直接利用官方仓库中的稳定版 PostgreSQL Chart 或者其他社区维护的良好 Chart 来完成安装工作。这里展示的是直接指定本地 Chart 路径的方式;如果使用远程 Chart,则不需要提供具体的文件夹位置[^3]。 另外,在执行上述命令之前,确保已经正确配置好了 Helm 环境,即完成了 Helm 和 Tiller 组件的初始化设置。Helm 客户端负责 chart 及其版本(release)的管理和与Tiller之间的通信,而 Tiller 则是在 Kubernetes 集群内部运行的服务,用来响应来自 Helm 客户端的操作请求并同 Kubernetes API Server 协作以实际创建资源对象。 最后,当 PostgreSQL 实例成功启动之后,可以通过下面的方法测试数据库服务是否正常运作: ```bash kubectl run gitlib-db-postgresql-client \ --rm --tty -i --restart='Never' \ --namespace gitlab \ --image registry.cn-shanghai.aliyuncs.com/wanfei/postgresql:14.2.0-debian-10-r35 \ --env="PGPASSWORD=$POSTGRES_PASSWORD" \ --command -- psql --host gitlib-db-postgresql -U wanfei -d gitlab-db -p 5432 ``` 这段脚本会临时创建一个新的 Pod 并在其内运行 `psql` 命令尝试连接目标 PostgreSQL 数据库实例,以此检验两者间的连通性和认证机制的有效性[^4]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值