1、网络拓扑图
2、华卓内网集群
内部k8s集群通过kube-vip与集群外部进行交互,通过ingress暴露kube-vip的80与443端口,出口流量为kube-vip的IP。
kube-vip通过静态pod的方式放在/etc/kubernetes/manifests/kube-vip.yaml。
#启动kube-vip
export VIP=x.x.x.x
export INTERFACE=ens192
docker run --rm plndr/kube-vip:v0.3.7 manifest pod \
--interface $INTERFACE \
--vip $VIP \
--controlplane \
--services \
--arp \
--leaderElection | tee /etc/kubernetes/manifests/kube-vip.yaml
sed -i 's/imagePullPolicy: Always/imagePullPolicy: IfNotPresent/g' /etc/kubernetes/manifests/kube-vip.yaml
#kube-vip配置文件
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
name: kube-vip
namespace: kube-system
spec:
containers:
- args:
- manager
env:
- name: vip_arp
value: "true"
- name: port
value: "6443"
- name: vip_interface
value: ens192
- name: vip_cidr
value: "32"
- name: cp_enable
value: "true"
- name: cp_namespace
value: kube-system
- name: vip_ddns
value: "false"
- name: svc_enable
value: "true"
- name: vip_leaderelection
value: "true"
- name: vip_leaseduration
value: "5"
- name: vip_renewdeadline
value: "3"
- name: vip_retryperiod
value: "1"
- name: vip_address
value: 172.16.255.26
- name: prometheus_server
value: :2112
image: ghcr.io/kube-vip/kube-vip:v0.5.5
imagePullPolicy: IfNotPresent
name: kube-vip
resources: {}
securityContext:
capabilities:
add:
- NET_ADMIN
- NET_RAW
volumeMounts:
- mountPath: /etc/kubernetes/admin.conf
name: kubeconfig
hostAliases:
- hostnames:
- kubernetes
ip: 127.0.0.1
hostNetwork: true
volumes:
- hostPath:
path: /etc/kubernetes/admin.conf
name: kubeconfig
3、甲方医院网络与代理
华卓内网k8s集群与第三方公司服务交互,或与其他医院服务交互,接通过内网核心转发,流量依旧出入口为kube-vip:
![image-20230711143734921](C:\Users\ROG Gaming\AppData\Roaming\Typora\typora-user-images\image-20230711143734921.png)
集群拉取镜像与告警通道,部署在DMZ区域的外网前置机服务器中,该外网前置机服务器位于网闸后面,与内网服务器映射需联系医院信息科进行配合,一般为80与443端口,集群内部服务的公网需求也都通过这台外网服务器进行转发。
![image-20230711144237252](C:\Users\ROG Gaming\AppData\Roaming\Typora\typora-user-images\image-20230711144237252.png)
4、代理服务器配置
代理服务器上需关闭防火墙,或与信息科沟通放开80与443端口。
systemctl stop firewalld
systemctl disable firewalld
squid配置参考:squid安装(linux) - 系统集成运维部 - Confluence (rubikstack.com)
集群内部服务的公网需求:
配置文件可以添加代理的:
在nacos配置文件中添加squid代理访问公网域名,例如:
net:
proxy:
enable: true
ur1: 192.46.203.50 #squid代理服务器IP
port: 31280
配置文件无法添加代理:
在pod中添加DNS解析,将需要访问的域名解析为代理服务器的IP,代理服务器通过docker启动goproxy容器正向代理,转发所有443端口的流量;
#添加hostAliases
#位置:spec.template.spec.hostAliases
hostAliases:
- ip: "192.46.203.50" #代理服务器IP
hostnames:
- "api.mch.weixin.qq.com"
- "www.baidu.com"
代理服务器启动goproxy:
#安装docker
1、配置docker的yum源
wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.cloud.tencent.com/docker-ce/linux/centos/docker-ce.repo
sed -i 's+download.docker.com+mirrors.cloud.tencent.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
2、安装相关依赖与常用RPM
yum install -y yum-utils device-mapper-persistent-data lvm2 wget telnet vim ca-certificates nfs-utils
3、安装docker
yum makecache fast
yum -y install docker-ce-19.03.15-3.el7 docker-ce-cli-19.03.15-3.el7
systemctl enable --now docker
4、修改docker配置文件
cat << EOF > /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"registry-mirrors": ["https://dockerproxy.com"],
"oom-score-adjust": -1000,
"insecure-registries": ["harbor.rubikstack.com"],
"log-driver": "json-file",
"log-opts": {
"max-size": "300m",
"max-file": "10"
},
"bip": "172.17.200.1/21",
"live-restore": true
}
EOF
#启动goproxy
docker run -d --name httpproxy443 --restart=on-failure -p 443:443 registry-hz.rubikstack.com/lichen/goproxy:latest /proxy http -p :443