我正在尝试使用负载均衡器和入口配置单节点 kubernetes clustor,但我无法从我的外部 IP 访问它。此外,如果我尝试卷曲/获取 LB 的内部 IP,它不起作用。我可以适当地卷曲/获取服务本身。谁能帮我?
配置
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: test-ingress
spec:
rules:
- host: MY_DOMAIN
http:
paths:
- path: /
backend:
serviceName: apple-service
servicePort: 5678
---
kind: Service
apiVersion: v1
metadata:
name: ingress-nginx
labels:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
spec:
type: LoadBalancer
selector:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
ports:
- name: http
port: 80
targetPort: 80
- name: https
port: 443
targetPort: 443
externalIPs:
- XX.XX.XX.XX
---
kind: Pod
apiVersion: v1
metadata:
name: apple-app
labels:
app: apple
spec:
containers:
- name: apple-app
image: hashicorp/http-echo
args:
- "-text=apple"
---
kind: Service
apiVersion: v1
metadata:
name: apple-service
spec:
selector:
app: apple
ports:
- port: 5678 # Default port for image
库贝克特尔 得到全部
NAME READY STATUS RESTARTS AGE
pod/apple-app 1/1 Running 0 12m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/apple-service ClusterIP 10.108.8.152 <none> 5678/TCP 12m
service/ingress-nginx LoadBalancer 10.111.230.95 XX.XX.XX.XX 80:30338/TCP,443:31035/TCP 10m
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 6d
kubectl get ingress
NAME HOSTS ADDRESS PORTS AGE
test-ingress * 80 6d
curl 10.107.97.101:5678
apple
curl XX.XX.XX.XX:80 (外部 IP(|本地主机:80|MY_DOMAIN:80
curl: (7) Failed to connect to XX.XX.XX.XX port 80: Connection refused
安装
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
mkdir $HOME/.kube -p
sudo cp /etc/kubernetes/admin.conf $HOME/.kube/
sudo chown $(id -u):$(id -g) $HOME/.kube/admin.conf
export KUBECONFIG=$HOME/.kube/admin.conf
echo "export KUBECONFIG=$HOME/.kube/admin.conf" | tee -a ~/.bashrc
# flanel
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.9.1/Documentation/k8s-manifests/kube-flannel-rbac.yml
# untained master to use as container host
kubectl taint nodes --all node-role.kubernetes.io/master-
# Install helm - for lets encrypt
sudo snap install helm --classic
PATH=$PATH:/snap/bin
# enable helm
helm init
helm install --name cert-manager -f cert-manager-values.yaml --namespace=default stable/cert-manager --set rbac.create=false
helm repo add jetstack https://charts.jetstack.io
# create letsencrypt
kubectl create namespace cert-manager
kubectl label namespace cert-manager certmanager.k8s.io/disable-validation=true
kubectl apply -f https://raw.githubusercontent.com/jetstack/cert-manager/release-0.8/deploy/manifests/00-crds.yaml
嗨@Fabi您在测试入口规范中的服务名称应该是
服务名称:苹果服务
并删除
外部流量策略:本地
来自您的入口-nginx 服务规范。
将您的入口规范编辑为此:
apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata: name: test-ingress spec: rules: - host: * http: paths: - path: /* backend: serviceName: apple-service servicePort: 5678