步骤:
创建k8s集群
创建nginx-ingress
设置私服访问权限
部署应用
创建服务
配置nginx-ingress规则
部署prometheus监控
安装coredns并配置host
自建snat
iptables -I FORWARD -s需转发的ip -j ACCEPT
iptables -t nat -I POSTROUTING -s需转发的ip -j SNAT --to-source服务器的ip
设置k8s的私服访问权限
kubectl create secret docker-registry password名称 --docker-server=hub私服地址 --docker-username=用户名 --docker-password=密码 --docker-email=用户名 --namespace=命名空间
创建服务
kubectl expose deployment nginx --port=port --target-port=port
nginx-ingress 配置:
"rules": [
{
"host": "域名",
"http": {
"paths": [
{
"path": "/",
"backend": {
"serviceName": "服务名",
"servicePort": 端口
}
}
]
}
}]
配置coredns:
hosts {
172.16.65.24 eureka
172.16.65.24 pinpoint
172.16.65.24 zk
fallthrough
}
"livenessProbe": {
"httpGet": {
"path": "/",
"port": 888,
"scheme": "HTTP"
},
"initialDelaySeconds": 3,
"timeoutSeconds": 1,
"periodSeconds": 5,
"successThreshold": 1,
"failureThreshold": 3
},
网友评论