update
This commit is contained in:
69
k8s/xiongxiao.me/config/helm.md
Normal file
69
k8s/xiongxiao.me/config/helm.md
Normal file
@@ -0,0 +1,69 @@
|
||||
# Helm 安装和使用指南
|
||||
|
||||
## 安装 Helm
|
||||
|
||||
### 最新版地址
|
||||
请访问 [Helm 官方下载页面](https://helm.sh/docs/intro/install/) 获取最新版本的下载链接。
|
||||
### Linux/macOS
|
||||
```bash
|
||||
|
||||
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-4
|
||||
chmod 700 get_helm.sh
|
||||
./get_helm.sh
|
||||
```
|
||||
### 直接下载二进制文件
|
||||
```bash
|
||||
curl https://get.helm.sh/helm-v4.0.1-linux-amd64.tar.gz | tar xz
|
||||
sudo mv linux-amd64/helm /usr/local/bin/
|
||||
```
|
||||
|
||||
### Windows (使用 Chocolatey)
|
||||
```bash
|
||||
choco install kubernetes-helm
|
||||
```
|
||||
|
||||
## 基本使用
|
||||
|
||||
### 添加 Chart 仓库
|
||||
```bash
|
||||
helm repo add stable https://charts.helm.sh/stable
|
||||
helm repo add bitnami https://charts.bitnami.com/
|
||||
helm repo update
|
||||
```
|
||||
|
||||
### 搜索 Chart
|
||||
```bash
|
||||
helm search repo nginx
|
||||
```
|
||||
|
||||
### 安装应用
|
||||
```bash
|
||||
helm install my-nginx bitnami/nginx
|
||||
```
|
||||
|
||||
### 查看安装的 Release
|
||||
```bash
|
||||
helm list
|
||||
```
|
||||
|
||||
### 卸载应用
|
||||
```bash
|
||||
helm uninstall my-nginx
|
||||
```
|
||||
|
||||
## 自定义配置
|
||||
|
||||
创建 `values.yaml` 文件:
|
||||
```yaml
|
||||
replicaCount: 3
|
||||
image:
|
||||
tag: "1.21"
|
||||
service:
|
||||
type: NodePort
|
||||
port: 80
|
||||
```
|
||||
|
||||
安装时使用自定义配置:
|
||||
```bash
|
||||
helm install my-app ./my-chart -f values.yaml
|
||||
```
|
||||
81
k8s/xiongxiao.me/config/kubectl-client.md
Normal file
81
k8s/xiongxiao.me/config/kubectl-client.md
Normal file
@@ -0,0 +1,81 @@
|
||||
# Kubectl 客户端安装和使用指南
|
||||
|
||||
## 安装 Kubectl 客户端
|
||||
|
||||
### 方法一:使用 curl(推荐)
|
||||
|
||||
```bash
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||
|
||||
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
|
||||
```
|
||||
|
||||
### 方法二:使用包管理器
|
||||
|
||||
**Ubuntu/Debian:**
|
||||
```bash
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y apt-transport-https ca-certificates curl
|
||||
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
|
||||
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y kubectl
|
||||
```
|
||||
### 验证安装
|
||||
|
||||
```bash
|
||||
kubectl version --client
|
||||
```
|
||||
|
||||
|
||||
### 配置 ~/.kube/config
|
||||
|
||||
**方法一:手动创建配置文件**
|
||||
|
||||
```bash
|
||||
mkdir -p ~/.kube
|
||||
cat > ~/.kube/config << EOF
|
||||
apiVersion: v1
|
||||
clusters:
|
||||
- cluster:
|
||||
server: https://your-k8s-api-server:6443
|
||||
insecure-skip-tls-verify: true
|
||||
name: my-cluster
|
||||
contexts:
|
||||
- context:
|
||||
cluster: my-cluster
|
||||
user: my-user
|
||||
name: my-context
|
||||
current-context: my-context
|
||||
kind: Config
|
||||
preferences: {}
|
||||
users:
|
||||
- name: my-user
|
||||
user:
|
||||
token: your-auth-token
|
||||
EOF
|
||||
```
|
||||
|
||||
**方法二:使用 kubectl config 命令**
|
||||
|
||||
```bash
|
||||
kubectl config set-cluster my-cluster --server=https://your-k8s-api-server:6443 --insecure-skip-tls-verify=true
|
||||
kubectl config set-credentials my-user --token=your-auth-token
|
||||
kubectl config set-context my-context --cluster=my-cluster --user=my-user
|
||||
kubectl config use-context my-context
|
||||
```
|
||||
|
||||
**方法三:复制服务器配置文件**
|
||||
|
||||
```bash
|
||||
# 从 Kubernetes 服务器复制配置文件到本地
|
||||
scp root@your-k8s-master:/etc/kubernetes/admin.conf ~/.kube/config
|
||||
chmod 600 ~/.kube/config
|
||||
```
|
||||
|
||||
### 验证配置
|
||||
|
||||
```bash
|
||||
kubectl cluster-info
|
||||
kubectl get nodes
|
||||
```
|
||||
Reference in New Issue
Block a user