This commit is contained in:
@@ -12,30 +12,25 @@
|
|||||||
docker image history app:v1
|
docker image history app:v1
|
||||||
```
|
```
|
||||||
|
|
||||||
## Docker镜像批量打包
|
## 拉取镜像命令
|
||||||
|
|
||||||
第一种
|
- 普通拉取镜像命令
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker save $(docker images | grep -v REPOSITORY | awk 'BEGIN{OFS=":";ORS=" "}{print $1,$2}') -o images.tar
|
docker pull nginx:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
第二种
|
- 拉取 AMD64 镜像命令
|
||||||
|
|
||||||
> 将需要统一打包的镜像写在文件内
|
```bash
|
||||||
|
docker pull --platform linux/amd64 nginx:latest
|
||||||
|
```
|
||||||
|
|
||||||
```bash
|
- 拉取 ARM64 镜像命令
|
||||||
cat > images.txt <<EOF
|
|
||||||
nginx:alpine
|
|
||||||
nginx:latest
|
|
||||||
EOF
|
|
||||||
```
|
|
||||||
|
|
||||||
打包
|
```bash
|
||||||
|
docker pull --platform linux/arm64 nginx:latest
|
||||||
```bash
|
```
|
||||||
docker save -o images.tar.gz $(cat images.txt)
|
|
||||||
```
|
|
||||||
|
|
||||||
## 清理资源命令
|
## 清理资源命令
|
||||||
|
|
||||||
@@ -45,6 +40,12 @@ docker save -o images.tar.gz $(cat images.txt)
|
|||||||
docker rm $(docker ps -q -f status=exited)
|
docker rm $(docker ps -q -f status=exited)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- 批量删除所有容器
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker rm -f $(docker ps -a --format "{{.Names}}")
|
||||||
|
```
|
||||||
|
|
||||||
- 移除所有没有使用的镜像
|
- 移除所有没有使用的镜像
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -3,31 +3,114 @@ kind: IstioOperator
|
|||||||
metadata:
|
metadata:
|
||||||
namespace: istio-system
|
namespace: istio-system
|
||||||
spec:
|
spec:
|
||||||
hub: docker.io/istio
|
# default: 最小化配置,需要按需开启功能
|
||||||
tag: 1.28.1
|
profile: default
|
||||||
|
# 镜像配置
|
||||||
|
hub: docker.io/istio # 镜像仓库地址
|
||||||
|
tag: 1.28.1 # 生产环境应使用稳定版本
|
||||||
|
|
||||||
|
# 组件配置
|
||||||
components:
|
components:
|
||||||
|
# Istio 基础组件(CRD 等)
|
||||||
base:
|
base:
|
||||||
enabled: true # Istio 基础组件
|
enabled: true
|
||||||
|
|
||||||
|
# Istiod - 控制平面核心组件
|
||||||
pilot:
|
pilot:
|
||||||
enabled: true # Istio 控制平面(Istiod)
|
enabled: true
|
||||||
# 进出口流量启用
|
k8s:
|
||||||
|
# 生产环境建议至少 2 个副本确保高可用
|
||||||
|
replicaCount: 2
|
||||||
|
# 资源配置建议
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 500m
|
||||||
|
memory: 1024Mi
|
||||||
|
limits:
|
||||||
|
cpu: 1000m
|
||||||
|
memory: 2048Mi
|
||||||
|
# 设置 Pod 反亲和性,避免同一节点故障导致服务中断
|
||||||
|
affinity:
|
||||||
|
podAntiAffinity:
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- weight: 100
|
||||||
|
podAffinityTerm:
|
||||||
|
labelSelector:
|
||||||
|
matchExpressions:
|
||||||
|
- key: istio
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- pilot
|
||||||
|
topologyKey: kubernetes.io/hostname
|
||||||
|
# 配置 HPA 自动伸缩
|
||||||
|
hpaSpec:
|
||||||
|
minReplicas: 2
|
||||||
|
maxReplicas: 5
|
||||||
|
metrics:
|
||||||
|
- type: Resource
|
||||||
|
resource:
|
||||||
|
name: cpu
|
||||||
|
target:
|
||||||
|
type: Utilization
|
||||||
|
averageUtilization: 70
|
||||||
|
|
||||||
|
# Ingress Gateway - 入口流量网关
|
||||||
ingressGateways:
|
ingressGateways:
|
||||||
- name: istio-ingressgateway
|
- name: istio-ingressgateway
|
||||||
enabled: true
|
enabled: true
|
||||||
|
k8s:
|
||||||
|
# 生产环境副本数建议 2 以上
|
||||||
|
replicaCount: 1
|
||||||
|
# 资源配置建议(根据实际流量调整)
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 512Mi
|
||||||
|
limits:
|
||||||
|
cpu: 1000m
|
||||||
|
memory: 1024Mi
|
||||||
|
# 服务配置
|
||||||
|
service:
|
||||||
|
type: LoadBalancer # 生产环境推荐使用 LoadBalancer
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
targetPort: 8080
|
||||||
|
name: http2
|
||||||
|
protocol: TCP
|
||||||
|
- port: 443
|
||||||
|
targetPort: 8443
|
||||||
|
name: https
|
||||||
|
protocol: TCP
|
||||||
|
|
||||||
|
# Egress Gateway - 出口流量网关(生产环境建议启用以控制出口流量)
|
||||||
egressGateways:
|
egressGateways:
|
||||||
- name: istio-egressgateway
|
- name: istio-egressgateway
|
||||||
enabled: false
|
enabled: true # 生产环境建议启用以控制出口流量
|
||||||
|
k8s:
|
||||||
# Most default values come from the helm chart's values.yaml
|
replicaCount: 1
|
||||||
# Below are the things that differ
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 512Mi
|
||||||
|
limits:
|
||||||
|
cpu: 1000m
|
||||||
|
memory: 1024Mi
|
||||||
|
|
||||||
|
# 值配置
|
||||||
values:
|
values:
|
||||||
defaultRevision: "" # 控制 sidecar 注入的默认版本
|
defaultRevision: "" # 控制 sidecar 注入的默认版本
|
||||||
|
|
||||||
|
# 全局配置
|
||||||
global:
|
global:
|
||||||
istioNamespace: istio-system # Istio 安装的命名空间
|
istioNamespace: istio-system # Istio 安装的命名空间
|
||||||
configValidation: true # 启用配置验证
|
configValidation: true # 启用配置验证
|
||||||
|
|
||||||
|
# 网关配置
|
||||||
gateways:
|
gateways:
|
||||||
istio-ingressgateway: {}
|
istio-ingressgateway: {}
|
||||||
istio-egressgateway: {}
|
istio-egressgateway: {}
|
||||||
|
|
||||||
|
# Ztunnel 配置(用于 Ambient Mesh)
|
||||||
ztunnel:
|
ztunnel:
|
||||||
resourceName: ztunnel # 为 Ztunnel DaemonSet 指定名称
|
# 资源名称
|
||||||
|
resourceName: ztunnel
|
||||||
206
网关/Istio/Istio安装和使用.md
Normal file
206
网关/Istio/Istio安装和使用.md
Normal file
@@ -0,0 +1,206 @@
|
|||||||
|
> 本文作者:丁辉
|
||||||
|
|
||||||
|
# Istio安装和使用
|
||||||
|
|
||||||
|
[官方文档](https://istio.io/latest/docs/) [官方中文文档](https://istio.io/latest/zh/docs/) [Github](https://github.com/istio/istio)
|
||||||
|
|
||||||
|
## 安装
|
||||||
|
|
||||||
|
[Github下载](https://github.com/istio/istio/releases)
|
||||||
|
|
||||||
|
### 下载二进制文件
|
||||||
|
|
||||||
|
1. 脚本下载(因国内网络问题建议从 Github 直接下载安装包)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -L https://istio.io/downloadIstio | sh -
|
||||||
|
```
|
||||||
|
|
||||||
|
解压文件
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tar -zxvf istio-*-linux-amd64.tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 进入目录
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd istio-1.28.1
|
||||||
|
```
|
||||||
|
|
||||||
|
3. 传递本地变量
|
||||||
|
|
||||||
|
- 临时
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export PATH=$PWD/bin:$PATH
|
||||||
|
```
|
||||||
|
|
||||||
|
- 永久
|
||||||
|
|
||||||
|
```bash
|
||||||
|
install -o root -g root -m 0755 ./bin/istioctl /usr/local/bin/istioctl
|
||||||
|
```
|
||||||
|
|
||||||
|
4. 验证
|
||||||
|
|
||||||
|
```bash
|
||||||
|
istioctl version
|
||||||
|
```
|
||||||
|
|
||||||
|
### 安装 Istio
|
||||||
|
|
||||||
|
查看内置的 Profile
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ls $(dirname $(which istioctl))/../manifests/profiles/
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 介绍
|
||||||
|
|
||||||
|
**Istio Profiles 应用场景对比表**
|
||||||
|
|
||||||
|
| Profile 名称 | 核心组件 | 资源需求 | 主要应用场景 | 特点 |
|
||||||
|
| :--------------------------: | :---------------------: | :------: | :----------------------------------------------------------: | :----------------------------------------------------------: |
|
||||||
|
| **`ambient.yaml`** | Ztunnel + CNI + Istiod | 中等 | 1. 环境网格(Ambient Mesh)部署 2. 无 sidecar 的服务网格 3. 大型集群优化 | • 无需注入 sidecar • 节点级 Ztunnel • 低侵入性 |
|
||||||
|
| **`default.yaml`** | Istiod + Ingress+Egress | 中等 | 1. 生产环境推荐配置 2. 大多数企业场景 3. 标准 sidecar 模式 | • 平衡功能与性能 • 包含 ingress/egress • 可扩展的基础配置 |
|
||||||
|
| **`demo.yaml`** | 全功能套件 | 高 | 1. 演示和展示 2. 测试环境 3. 功能验证 | • 启用所有组件 • 高资源消耗 • 不适合生产 |
|
||||||
|
| **`minimal.yaml`** | 仅 Istiod | 低 | 1. 仅控制平面 2. 远程集群配置 3. 最小化部署 | • 只安装 Istiod • 无数据平面组件 • 需手动配置网关 |
|
||||||
|
| **`empty.yaml`** | 无 | 无 | 1. 完全自定义起点 2. 作为模板使用 3. 特定场景定制 | • 空配置 • 需要手动定义所有组件 • 专家级使用 |
|
||||||
|
| **`preview.yaml`** | 实验性功能 | 可变 | 1. 测试新特性 2. 评估预览功能 3. 技术预览 | • 包含实验性组件 • 可能不稳定 • 不建议生产 |
|
||||||
|
| **`remote.yaml`** | Istiod(简化) | 低 | 1. 多集群主-从配置 2. 共享控制平面 3. 边缘集群 | • 为远程集群优化 • 精简的 Istiod • 与主集群配合 |
|
||||||
|
| **`stable.yaml`** | 稳定组件集 | 中等 | 1. 生产环境稳定版 2. 长期支持场景 3. 关键业务系统 | • 仅包含稳定组件 • 排除实验性功能 • 高可靠性 |
|
||||||
|
| **`openshift.yaml`** | OpenShift 适配 | 中等 | 1. Red Hat OpenShift 平台 2. 企业 K8s 发行版 | • OpenShift 特定配置 • 安全上下文适配 • SCC(安全上下文约束) |
|
||||||
|
| **`openshift-ambient.yaml`** | Ztunnel + OpenShift | 中等 | 1. OpenShift + Ambient Mesh 2. 企业级无 sidecar 网格 | • Ambient Mesh + OpenShift 适配 • 企业环境优化 |
|
||||||
|
|
||||||
|
**详细场景说明**
|
||||||
|
|
||||||
|
1. **新手/学习场景**
|
||||||
|
- **推荐:`demo.yaml`**
|
||||||
|
- **原因**:快速体验 Istio 全功能,便于学习和演示
|
||||||
|
- **注意**:资源消耗大,仅用于非生产环境
|
||||||
|
2. **生产环境**
|
||||||
|
- **保守选择:`stable.yaml`**
|
||||||
|
- 追求最高稳定性
|
||||||
|
- 避免实验性功能的风险
|
||||||
|
- **标准选择:`default.yaml`**
|
||||||
|
- 功能完整且稳定
|
||||||
|
- 社区广泛验证
|
||||||
|
- **创新选择:`ambient.yaml`**
|
||||||
|
- 追求新技术优势
|
||||||
|
- 需要评估兼容性
|
||||||
|
3. ** 资源受限环境**
|
||||||
|
- **小集群/边缘:`minimal.yaml`**
|
||||||
|
- 按需添加网关
|
||||||
|
- 控制平面和数据平面分离部署
|
||||||
|
- **开发测试:`default.yaml`**
|
||||||
|
- 兼顾功能与资源
|
||||||
|
4. **特定平台**
|
||||||
|
- **OpenShift:`openshift.yaml`**
|
||||||
|
- 自动处理安全策略
|
||||||
|
- 平台集成优化
|
||||||
|
- **多集群:`remote.yaml`**
|
||||||
|
- 从集群使用精简配置
|
||||||
|
- 主集群使用 `default.yaml`
|
||||||
|
5. **高级用户**
|
||||||
|
- **完全自定义:`empty.yaml`**
|
||||||
|
- 作为配置模板
|
||||||
|
- 构建专属配置
|
||||||
|
- **评估新特性:`preview.yaml`**
|
||||||
|
- 测试即将发布的功能
|
||||||
|
- 技术选型评估
|
||||||
|
|
||||||
|
**选择建议流程图**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
是否需要特定平台?
|
||||||
|
├── OpenShift 平台 → openshift.yaml 或 openshift-ambient.yaml
|
||||||
|
└── 其他平台 → 继续评估
|
||||||
|
↓
|
||||||
|
追求新技术还是稳定性?
|
||||||
|
├── 追求新技术 → ambient.yaml
|
||||||
|
├── 最高稳定性 → stable.yaml
|
||||||
|
└── 平衡选择 → default.yaml
|
||||||
|
↓
|
||||||
|
资源是否紧张?
|
||||||
|
├── 资源充足 → default.yaml
|
||||||
|
└── 资源紧张 → minimal.yaml + 按需组件
|
||||||
|
↓
|
||||||
|
是否用于演示/学习?
|
||||||
|
├── 是 → demo.yaml
|
||||||
|
└── 否 → 维持之前选择
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 开始部署
|
||||||
|
|
||||||
|
- 测试环境
|
||||||
|
|
||||||
|
```bash
|
||||||
|
istioctl install --set profile=demo -y
|
||||||
|
```
|
||||||
|
|
||||||
|
- 生产环境
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
wget https://gitee.com/offends/Kubernetes/raw/main/File/Yaml/istio-config.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
> 根据自己生产环境需求修改文件内参数,文件内参数我尽可能更新偏向于生产环境。
|
||||||
|
|
||||||
|
部署
|
||||||
|
|
||||||
|
```bash
|
||||||
|
istioctl install -f istio-config.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
1. 为默认命名空间添加标签,以便在稍后部署应用程序时自动注入 Envoy sidecar 代理
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl label namespace default istio-injection=enabled
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 检查并安装 API CRD
|
||||||
|
|
||||||
|
- Kubernetes Gateway API CRD(新版支持)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl get crd gateways.gateway.networking.k8s.io &> /dev/null || \
|
||||||
|
{ kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd?ref=v1.4.0" | kubectl apply -f -; }
|
||||||
|
```
|
||||||
|
|
||||||
|
- (旧版将来即将不支持)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
暂时不做记录
|
||||||
|
```
|
||||||
|
|
||||||
|
### 卸载 Istio
|
||||||
|
|
||||||
|
1. 删除命名空间标签
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl label namespace default istio-injection-
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 卸载 Istio
|
||||||
|
|
||||||
|
```bash
|
||||||
|
istioctl uninstall --purge -y
|
||||||
|
```
|
||||||
|
|
||||||
|
## Istioctl命令使用
|
||||||
|
|
||||||
|
- 生成 Istio 安装清单(查看 Istio 将要创建的所有 Kubernetes 资源)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
istioctl manifest generate > generated-manifest.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
- 诊断命令,用于静态分析 Istio 配置和资源,以检测潜在的问题、错误配置或最佳实践违规
|
||||||
|
|
||||||
|
```bash
|
||||||
|
istioctl analyze
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
74
部署文档/管理平台安装/Kuboard/Kuboard管理Kubernetes.md
Normal file
74
部署文档/管理平台安装/Kuboard/Kuboard管理Kubernetes.md
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
> 本文作者:丁辉
|
||||||
|
|
||||||
|
# Kuboard管理Kubernetes
|
||||||
|
|
||||||
|
[Docker内安装文档]() [Kubernetes内安装文档](https://kuboard.cn/install/v3/install-in-k8s.html)
|
||||||
|
|
||||||
|
## 部署Kuboard
|
||||||
|
|
||||||
|
### Docker部署(推荐)
|
||||||
|
|
||||||
|
> 官方说法:在普通部署模式下 Kuboard 通常只部署了一个容器实例,存在单点故障,因此 Kuboard 本身并不能保证高可用。但是在 Kuboard 出现故障时,并不影响 Kubernetes 的正常,因此,普通部署模式下安装的 Kuboard 是可以满足绝大部分用户的需求的。普通部署模式下,当 Kuboard 出现故障时,可以重新部署一个 Kuboard,并导入 Kubernetes 到新的 Kuboard 实例,即可恢复故障。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo docker run -d \
|
||||||
|
--restart=unless-stopped \
|
||||||
|
--privileged \
|
||||||
|
--name=kuboard \
|
||||||
|
-p 80:80/tcp \
|
||||||
|
-p 10081:10081/tcp \
|
||||||
|
-e KUBOARD_ENDPOINT="http://内网IP:80" \
|
||||||
|
-e KUBOARD_AGENT_SERVER_TCP_PORT="10081" \
|
||||||
|
-v /root/kuboard-data:/data \
|
||||||
|
swr.cn-east-2.myhuaweicloud.com/kuboard/kuboard:v3
|
||||||
|
```
|
||||||
|
|
||||||
|
### Kubernetes部署
|
||||||
|
|
||||||
|
1. 创建数据存储目录
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir -p /usr/share/kuboard/etcd/ && chmod 700 /usr/share/kuboard/etcd/
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 部署Kuboard
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl apply -f https://addons.kuboard.cn/kuboard/kuboard-v3.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
> 某些情况下,您的 Master 节点只有一个或者两个,却仍然想要保证 Kubuoard-Etcd 的高可用,此时,您可以通过为一到两个 Worker 节点添加 `k8s.kuboard.cn/role=etcd` 的标签,来增加 Kubuoard-Etcd 的实例数量
|
||||||
|
>
|
||||||
|
> ```bash
|
||||||
|
> kubectl label nodes <Worker-Node-Name> k8s.kuboard.cn/role=etcd
|
||||||
|
> ```
|
||||||
|
|
||||||
|
3. 部署
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl apply -f https://addons.kuboard.cn/kuboard/kuboard-v3.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
### 使用 StorageClass 提供持久化部署
|
||||||
|
|
||||||
|
[官方文档](https://kuboard.cn/install/v3/install-in-k8s.html#%E6%96%B9%E6%B3%95%E4%BA%8C-%E4%BD%BF%E7%94%A8-storageclass-%E6%8F%90%E4%BE%9B%E6%8C%81%E4%B9%85%E5%8C%96)
|
||||||
|
|
||||||
|
### 高可用部署
|
||||||
|
|
||||||
|
[官方文档](https://kuboard.cn/install/v3/install-ha.html#%E5%AE%89%E8%A3%85-kuboard-v3-%E9%AB%98%E5%8F%AF%E7%94%A8%E9%83%A8%E7%BD%B2)
|
||||||
|
|
||||||
|
## 卸载Kuboard
|
||||||
|
|
||||||
|
1. 卸载
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl delete -f https://addons.kuboard.cn/kuboard/kuboard-v3.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 删除数据
|
||||||
|
|
||||||
|
```bash
|
||||||
|
rm -rf /usr/share/kuboard
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user