Nginx 入口控制器无法 运行
Nginx ingress controller failed to run
我正在尝试在没有负载均衡器和云提供商的情况下在我自己的服务器中部署 nginx-ingress 控制器。我执行了以下步骤:
apiVersion: v1
kind: Namespace
metadata:
name: ingress-nginx
然后,我为 serviceAccount 创建了一个名为 nginx-ingress
的集群角色。
我的 nginx-controller-service.yaml
:
kind: Service
apiVersion: v1
metadata:
name: ingress-nginx
namespace: ingress-nginx
labels:
app: ingress-nginx
spec:
externalTrafficPolicy: Local
type: NodePort
selector:
app: ingress-nginx
ports:
- name: http
port: 80
targetPort: http
- name: https
port: 443
targetPort: https
externalIPs:
- my-external-node-ip
和nginx-ingress-controller.yaml
:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-ingress-controller
namespace: ingress-nginx
spec:
replicas: 1
selector:
matchLabels:
app: ingress-nginx
template:
metadata:
labels:
app: ingress-nginx
annotations:
prometheus.io/port: '10254'
prometheus.io/scrape: 'true'
spec:
serviceAccountName: nginx-ingress
containers:
- name: nginx-ingress-controller
image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.9.0-beta.17
args:
- /nginx-ingress-controller
- --default-backend-service=$(POD_NAMESPACE)/default-http-backend
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
ports:
- name: http
containerPort: 80
- name: https
containerPort: 443
livenessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: 10254
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
readinessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: 10254
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
但是,当我获得部署状态时,它显示:
NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
ingress-nginx deployment.apps/default-http-backend 1/1 1 1 17m
ingress-nginx deployment.apps/nginx-ingress-controller 0/1 0 0 17m
控制器不是available/not运行。
这里出了什么问题,如何获取失败部署的日志?
从服务清单中删除以下条目
externalTrafficPolicy: Local
externalIPs:
- my-external-node-ip
此问题是由于缺少 服务帐户造成的。
58m Warning FailedCreate ReplicaSet Error creating: pods "nginx-ingress-controller-5b7f66f95f-" is forbidden: error looking up service account ingress-nginx/nginx-ingress: serviceaccount "nginx-ingress" not found
您可以使用以下命令创建 SA
kubectl create serviceaccount my-service-account
了解更多详情 k8s-service-account
我正在尝试在没有负载均衡器和云提供商的情况下在我自己的服务器中部署 nginx-ingress 控制器。我执行了以下步骤:
apiVersion: v1
kind: Namespace
metadata:
name: ingress-nginx
然后,我为 serviceAccount 创建了一个名为 nginx-ingress
的集群角色。
我的 nginx-controller-service.yaml
:
kind: Service
apiVersion: v1
metadata:
name: ingress-nginx
namespace: ingress-nginx
labels:
app: ingress-nginx
spec:
externalTrafficPolicy: Local
type: NodePort
selector:
app: ingress-nginx
ports:
- name: http
port: 80
targetPort: http
- name: https
port: 443
targetPort: https
externalIPs:
- my-external-node-ip
和nginx-ingress-controller.yaml
:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-ingress-controller
namespace: ingress-nginx
spec:
replicas: 1
selector:
matchLabels:
app: ingress-nginx
template:
metadata:
labels:
app: ingress-nginx
annotations:
prometheus.io/port: '10254'
prometheus.io/scrape: 'true'
spec:
serviceAccountName: nginx-ingress
containers:
- name: nginx-ingress-controller
image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.9.0-beta.17
args:
- /nginx-ingress-controller
- --default-backend-service=$(POD_NAMESPACE)/default-http-backend
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
ports:
- name: http
containerPort: 80
- name: https
containerPort: 443
livenessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: 10254
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
readinessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: 10254
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
但是,当我获得部署状态时,它显示:
NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
ingress-nginx deployment.apps/default-http-backend 1/1 1 1 17m
ingress-nginx deployment.apps/nginx-ingress-controller 0/1 0 0 17m
控制器不是available/not运行。
这里出了什么问题,如何获取失败部署的日志?
从服务清单中删除以下条目
externalTrafficPolicy: Local
externalIPs:
- my-external-node-ip
此问题是由于缺少 服务帐户造成的。
58m Warning FailedCreate ReplicaSet Error creating: pods "nginx-ingress-controller-5b7f66f95f-" is forbidden: error looking up service account ingress-nginx/nginx-ingress: serviceaccount "nginx-ingress" not found
您可以使用以下命令创建 SA
kubectl create serviceaccount my-service-account
了解更多详情 k8s-service-account