惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

aimingoo的专栏
aimingoo的专栏
Google DeepMind News
Google DeepMind News
S
SegmentFault 最新的问题
Project Zero
Project Zero
D
DataBreaches.Net
I
InfoQ
L
Lohrmann on Cybersecurity
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
酷 壳 – CoolShell
酷 壳 – CoolShell
Stack Overflow Blog
Stack Overflow Blog
The Register - Security
The Register - Security
Recorded Future
Recorded Future
Vercel News
Vercel News
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
I
Intezer
The Hacker News
The Hacker News
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
Help Net Security
Help Net Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Scott Helme
Scott Helme
T
Threatpost
爱范儿
爱范儿
N
Netflix TechBlog - Medium
D
Docker
云风的 BLOG
云风的 BLOG
C
Cisco Blogs
K
Kaspersky official blog
H
Help Net Security
S
Secure Thoughts
T
Threat Research - Cisco Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
Security @ Cisco Blogs
Cyberwarzone
Cyberwarzone
N
News and Events Feed by Topic
G
Google Developers Blog
Forbes - Security
Forbes - Security
博客园 - 三生石上(FineUI控件)
博客园 - 叶小钗
B
Blog
Google DeepMind News
Google DeepMind News
Recent Announcements
Recent Announcements
Simon Willison's Weblog
Simon Willison's Weblog
S
Securelist
P
Privacy International News Feed
Spread Privacy
Spread Privacy
The Last Watchdog
The Last Watchdog

k8s on 打工人日志

k8s RKE2 cilium L2 + envoy gateway 安装配置 k8s RKE2 vSphere 存储配置 Kubernetes — skywalking + banyanDB APM监控部署 Kubernetes — promtail + loki + grafana 日志系统部署 Kubernetes — metalLB + Traefik 部署 Kubernetes — SSL 证书自动更新 Kubernetes — RKE2 + kube-vip + cilium 部署 Kubernetes — k8s 手动安装 1.17.9 Kubernetes — containerd 安装和部署 Argo cd 安装和部署 Kubernetes — kubecost 分析 Kubernetes 成本 Ansible部署ceph集群 Kubernetes — 更新证书 Kubernetes — Rook云存储介绍和部署 Kubernetes — 基于K8S搭建Ceph分布式存储 Kubernetes — 探针和生命周期 Kubernetes — 开放标准(OCI、CRI、CNI、CSI、SMI、CPI)概述 kubernetes 部署插件 (Flannel、Web UI、CoreDNS、Ingress Controller) kubernetes 存储 kubernetes 从1.23.x 升级到 1.24.x 编写 kubernetes 资源描述文件 kubernetes manual expansion kubernetes 调度过程 k8s本地联调神器kt-connect OpenELB:让k8s私有环境对外暴露端口 kubernetes ansible自动化部署 kubernetes 脚本快速安装 kubernetes面试题汇总 Kubernetes 安装 Harbor 搭建 Kubernetes 实验手册(1) Keepalived高可用 helm 安装 k8s 部署loki日志 Kubernetes 创建nfs存储类 Kubernetes k8s 组件
metallb + ingress-nginx + argocd 本地部署
2025-06-10 · via k8s on 打工人日志

环境准备(配置代理)

proxy_setting.yml

 1---
 2- name: 设置全局代理并测试连接
 3  hosts: all
 4  become: yes
 5  vars:
 6    proxy_host: "10.10.10.254"
 7    proxy_port: "7890"
 8    http_proxy: "http://{{ proxy_host }}:{{ proxy_port }}"
 9    https_proxy: "http://{{ proxy_host }}:{{ proxy_port }}"
10    no_proxy: "localhost,127.0.0.1"
11
12  environment:
13    http_proxy: "{{ http_proxy }}"
14    https_proxy: "{{ https_proxy }}"
15    no_proxy: "{{ no_proxy }}"
16
17  tasks:
18    - name: 显示代理设置
19      debug:
20        msg:
21          - "HTTP Proxy: {{ http_proxy }}"
22          - "HTTPS Proxy: {{ https_proxy }}"
23          - "NO_PROXY: {{ no_proxy }}"
24
25    - name: 使用 curl 测试外部连接(使用代理)
26      command: curl -I https://www.google.com
27      register: curl_result
28      ignore_errors: yes
29
30    - name: 显示 curl 测试结果
31      debug:
32        var: curl_result.stdout_lines

执行:

1ansible-playbook -i /etc/ansible/hosts proxy_setting.yml

kubespray 安装 k8s

1git clone --depth=1 https://github.com/kubernetes-sigs/kubespray.git
2cd kubespray
3pip install -r requirements.txt
4cp -rfp inventory/sample inventory/mycluster

修改 kubespray/inventory/mycluster/group_vars/k8s_cluster.yml

 1# 选择网络插件,支持 cilium, calico, weave 和 flannel
 2kube_network_plugin: cilium
 3
 4# 设置 Service 网段
 5kube_service_addresses: 10.233.0.0/18
 6
 7# 设置 Pod 网段
 8kube_pods_subnet: 10.233.64.0/18
 9
10# 支持 docker, crio 和 containerd,推荐 containerd.
11container_manager: containerd
12
13# 是否开启 kata containers
14kata_containers_enabled: false
15
16# 是否开启自动更新证书,推荐开启。
17auto_renew_certificates: true

修改 inventory/mycluster/inventory.ini

1[kube_control_plane]                                                                                                         
2node151 ansible_host=10.10.10.151                                                
3                                                                                                                             
4[etcd:children]                                                                                             
5
6kube_control_plane                                                                                                              
7[kube_node]    
8node152 ansible_host=10.10.10.152
9node153 ansible_host=10.10.10.152

执行部署

1sudo ansible-playbook \
2  -i inventory/mycluster/inventory.ini \
3  --private-key=~/.ssh/id_rsa \
4  --user=ubuntu -b \
5  cluster.yml
1kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.12/config/manifests/metallb-native.yaml

等待组件运行:

1kubectl get pods -n metallb-system

配置 IP 地址池 你需要指定一段在内网中未被使用的 IP 段(例如 10.10.10.170-10.10.10.180),MetalLB 会从中自动分配。

 1# metallb-config.yaml
 2apiVersion: metallb.io/v1beta1
 3kind: IPAddressPool
 4metadata:
 5  name: local-pool
 6  namespace: metallb-system
 7spec:
 8  addresses:
 9    - 10.10.10.170-10.10.10.180  # ← 修改为你的局域网可用 IP
10---
11apiVersion: metallb.io/v1beta1
12kind: L2Advertisement
13metadata:
14  name: l2adv
15  namespace: metallb-system

应用配置

1kubectl apply -f metallb-config.yaml

测试验证

 1# test-lb.yaml
 2apiVersion: v1
 3kind: Service
 4metadata:
 5  name: nginx-lb
 6spec:
 7  selector:
 8    app: nginx
 9  type: LoadBalancer
10  ports:
11    - name: http
12      port: 80
13      targetPort: 80
14---
15apiVersion: apps/v1
16kind: Deployment
17metadata:
18  name: nginx
19spec:
20  replicas: 1
21  selector:
22    matchLabels:
23      app: nginx
24  template:
25    metadata:
26      labels:
27        app: nginx
28    spec:
29      containers:
30        - name: nginx
31          image: nginx:alpine
32          ports:
33            - containerPort: 80

应用测试服务

1kubectl apply -f test-lb.yaml

检查服务状态

1kubectl get svc nginx-lb

安装 Ingress nginx

1kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.12.3/deploy/static/
2provider/cloud/deploy.yaml 

等待组件运行:

1kubectl get pods -n ingress-nginx
2kubectl get svc -n ingress-nginx

切换为loadBalancer

1kubectl patch svc ingress-nginx-controller -n ingress-nginx -p '{"spec": {"type": "LoadBalancer"}}'

安装 argocd

1kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

等待组件运行:

1kubectl get pods -n argocd

创建argocd-ingress.yaml

 1apiVersion: networking.k8s.io/v1
 2kind: Ingress
 3metadata:
 4  name: argocd-ingress
 5  namespace: argocd
 6  annotations:
 7    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
 8    nginx.ingress.kubernetes.io/ssl-redirect: "true"
 9spec:
10  ingressClassName: nginx
11  rules:
12    - host: argocd.k8s.com
13      http:
14        paths:
15          - path: /
16            pathType: Prefix
17            backend:
18              service:
19                name: argocd-server
20                port:
21                  number: 443
22  tls:
23    - hosts:
24        - argocd.k8s.com
25      secretName: argocd-tls

创建 TLS 证书 Secret

1openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
2  -out argocd.crt -keyout argocd.key \
3  -subj "/CN=argocd.k8s.com/O=ArgoCD"
4
5kubectl create secret tls argocd-tls \
6  --cert=argocd.crt --key=argocd.key \
7  -n argocd

应用 Ingress 配置

1kubectl apply -f argocd-ingress.yaml

添加 hosts 映射(本地访问)

1kubectl get svc -n ingress-nginx
1NAME                                 TYPE           CLUSTER-IP      EXTERNAL-IP    PORT(S)                      AGE          
2ingress-nginx-controller             LoadBalancer   10.233.41.226   10.10.10.170   80:30776/TCP,443:30834/TCP   99m          
3ingress-nginx-controller-admission   ClusterIP      10.233.13.138                  443/TCP                      99m  

ingress-nginx 的 EXTERNAL-IP 是 10.10.10.170,你需要在本机添加:

110.10.10.170 argocd.k8s.com

获取初始密码

1kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo

访问 ArgoCD 界面

https://argocd.k8s.com