你好,我对 kubernates 还不太熟悉,所以我在 Ubuntu DPS 上安装了 kubernates,然后还添加了 ngnx-ingress-controllerkubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.35.0/deploy/static/provider/baremetal/deploy.yaml
我的部署是一个 React 应用程序,在端口 80 上运行 nginx:1.15
apiVersion: apps/v1
kind: Deployment
metadata:
name: clientweb-dep
labels:
appcluster: ethernial
app: clientweb
spec:
replicas: 1
selector:
matchLabels:
app: clientweb
template:
metadata:
name: clientweb-template
labels:
appcluster: ethernial
app: clientweb
spec:
containers:
- name: clientweb
image: ethernial.azurecr.io/clientweb
resources:
requests:
cpu: 100m
memory: 300Mi
env:
- name: APPNAME
value: clientweb
- name: CONTAINERNAME
value: clientweb
ports:
- containerPort: 80
name: http-port
imagePullSecrets:
- name: acr-secret
我的服务:
apiVersion: v1
kind: Service
metadata:
labels:
appcluster: ethernial
app: clientweb
name: clientweb-service
spec:
ports:
- port: 80
name: http
selector:
app: clientweb
type: ClusterIP
这是入口:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: clientweb-ingress
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- http:
paths:
- path: /?(.*)
backend:
serviceName: clientweb-service
servicePort: 80
但是当我访问 IP 或域名 URL 时,我得到了 502 Bad Gateway,那么我遗漏了什么呢?
kubectl 获取所有 -A -o 宽
master-node:/tmp/deps# kubectl get all -A -o wide
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
default pod/clientweb-dep-5d58cfb88f-f4ntq 1/1 Running 0 21d 10.244.0.21 master-node <none> <none>
default pod/portalapi-dep-c8845948b-7sf2w 1/1 Running 0 23d 10.244.0.20 master-node <none> <none>
ingress-nginx pod/ingress-nginx-admission-create-xnxrm 0/1 Completed 0 2d23h 10.244.0.22 master-node <none> <none>
ingress-nginx pod/ingress-nginx-admission-patch-6sq94 0/1 Completed 1 2d23h 10.244.0.23 master-node <none> <none>
ingress-nginx pod/ingress-nginx-controller-7896b4fbd4-ccn2n 1/1 Running 0 2d23h 10.244.0.24 master-node <none> <none>
kube-system pod/coredns-66bff467f8-46sgr 1/1 Running 0 51d 10.244.0.3 master-node <none> <none>
kube-system pod/coredns-66bff467f8-fnjn7 1/1 Running 0 51d 10.244.0.2 master-node <none> <none>
kube-system pod/etcd-master-node 1/1 Running 0 51d 62.75.216.101 master-node <none> <none>
kube-system pod/kube-apiserver-master-node 1/1 Running 1 51d 62.75.216.101 master-node <none> <none>
kube-system pod/kube-controller-manager-master-node 1/1 Running 23 51d 62.75.216.101 master-node <none> <none>
kube-system pod/kube-proxy-7r7vk 1/1 Running 0 51d 62.75.216.101 master-node <none> <none>
kube-system pod/kube-scheduler-master-node 1/1 Running 25 51d 62.75.216.101 master-node <none> <none>
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
default service/clientweb-service ClusterIP 10.103.212.174 <none> 80/TCP 2d23h app=clientweb
default service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 51d <none>
ingress-nginx service/ingress-nginx-controller NodePort 10.96.161.144 <none> 80:32335/TCP,443:31481/TCP 2d23h app.kubernetes.io/component=controller,app.kubernetes.io/instance=ingress-nginx,app.kubernetes.io/name=ingress-nginx
ingress-nginx service/ingress-nginx-controller-admission ClusterIP 10.98.123.43 <none> 443/TCP 2d23h app.kubernetes.io/component=controller,app.kubernetes.io/instance=ingress-nginx,app.kubernetes.io/name=ingress-nginx
kube-system service/kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 51d k8s-app=kube-dns
NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE CONTAINERS IMAGES SELECTOR
kube-system daemonset.apps/kube-proxy 1 1 1 1 1 kubernetes.io/os=linux 51d kube-proxy k8s.gcr.io/kube-proxy:v1.18.6 k8s-app=kube-proxy
NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
default deployment.apps/clientweb-dep 1/1 1 1 47d clientweb ethernial.azurecr.io/clientweb:26 app=clientweb
default deployment.apps/portalapi-dep 1/1 1 1 49d portalapi ethernial.azurecr.io/portalapi:22 app=portalapi
ingress-nginx deployment.apps/ingress-nginx-controller 1/1 1 1 2d23h controller k8s.gcr.io/ingress-nginx/controller:v0.35.0@sha256:fc4979d8b8443a831c9789b5155cded454cb7de737a8b727bc2ba0106d2eae8b app.kubernetes.io/component=controller,app.kubernetes.io/instance=ingress-nginx,app.kubernetes.io/name=ingress-nginx
kube-system deployment.apps/coredns 2/2 2 2 51d coredns k8s.gcr.io/coredns:1.6.7 k8s-app=kube-dns
NAMESPACE NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR
default replicaset.apps/clientweb-dep-5b96dc777b 0 0 0 47d clientweb ethernial.azurecr.io/clientweb:21 app=clientweb,pod-template-hash=5b96dc777b
default replicaset.apps/clientweb-dep-5d58cfb88f 1 1 1 21d clientweb ethernial.azurecr.io/clientweb:26 app=clientweb,pod-template-hash=5d58cfb88f
default replicaset.apps/portalapi-dep-857dfbf98 0 0 0 49d portalapi ethernial.azurecr.io/portalapi:16 app=portalapi,pod-template-hash=857dfbf98
default replicaset.apps/portalapi-dep-c8845948b 1 1 1 23d portalapi ethernial.azurecr.io/portalapi:22 app=portalapi,pod-template-hash=c8845948b
default replicaset.apps/portalapi-dep-cdf85c5cf 0 0 0 48d portalapi ethernial.azurecr.io/portalapi:18 app=portalapi,pod-template-hash=cdf85c5cf
ingress-nginx replicaset.apps/ingress-nginx-controller-7896b4fbd4 1 1 1 2d23h controller k8s.gcr.io/ingress-nginx/controller:v0.35.0@sha256:fc4979d8b8443a831c9789b5155cded454cb7de737a8b727bc2ba0106d2eae8b app.kubernetes.io/component=controller,app.kubernetes.io/instance=ingress-nginx,app.kubernetes.io/name=ingress-nginx,pod-template-hash=7896b4fbd4
kube-system replicaset.apps/coredns-66bff467f8 2 2 2 51d coredns k8s.gcr.io/coredns:1.6.7 k8s-app=kube-dns,pod-template-hash=66bff467f8
NAMESPACE NAME COMPLETIONS DURATION AGE CONTAINERS IMAGES SELECTOR
ingress-nginx job.batch/ingress-nginx-admission-create 1/1 24s 2d23h create docker.io/jettech/kube-webhook-certgen:v1.2.2 controller-uid=5f09375f-e7a5-4625-b7d1-37298975afad
ingress-nginx job.batch/ingress-nginx-admission-patch 1/1 30s 2d23h patch docker.io/jettech/kube-webhook-certgen:v1.2.2 controller-uid=23a26ffb-f2d8-4c4c-b361-b690a39befaa