kubernetes nginx入口控制器错误

时间:2018-05-18 22:23:54

标签: nginx kubernetes google-cloud-platform google-kubernetes-engine

我正在使用google kubenretes引擎。我的群集节点版本是1.7。由于Google云无法支持该版本创建新群集,因此我需要使用1.8或1.9。 我在新版本的集群中遇到了我的nginx-ingress-controller yaml文件的问题,但我一直收到这个错误:

     Using build: https://github.com/bprashanth/contrib.git - git-92b2bac when using gcr.io/google_containers/nginx-ingress-controller:0.8.3

使用quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.9.0时出现此错误

     It seems the cluster it is running with Authorization enabled (like RBAC) and there is no permissions for the ingress controller. Please check the configuration

这是我的nginx-ingress-controller文件

apiVersion: v1
kind: Service
metadata:
  name: default-http-backend
  labels:
   k8s-app: default-http-backend
spec:
  ports:
  - port: 80
    targetPort: 8080
    protocol: TCP
    name: http
  selector:
    k8s-app: default-http-backend
---
apiVersion: v1
kind: ReplicationController
metadata:
  name: default-http-backend
spec:
  replicas: 1
  selector:
    k8s-app: default-http-backend
  template:
    metadata:
      labels:
        k8s-app: default-http-backend
    spec:
      terminationGracePeriodSeconds: 60
      containers:
      - name: default-http-backend
        # Any image is permissable as long as:
        # 1. It serves a 404 page at /
        # 2. It serves 200 on a /healthz endpoint
        image: gcr.io/google_containers/defaultbackend:1.0
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8080
            scheme: HTTP
          initialDelaySeconds: 30
          timeoutSeconds: 5
        ports:
        - containerPort: 8080
        resources:
          limits:
            cpu: 10m
            memory: 20Mi
          requests:
            cpu: 10m
            memory: 20Mi
---
apiVersion: v1
kind: ReplicationController
metadata:
  name: nginx-ingress-controller
  labels:
    k8s-app: nginx-ingress-lb
spec:
  replicas: 1
  selector:
    k8s-app: nginx-ingress-lb
  template:
    metadata:
      labels:
        k8s-app: nginx-ingress-lb
        name: nginx-ingress-lb
    spec:
      terminationGracePeriodSeconds: 60
      containers:
      - image: gcr.io/google_containers/nginx-ingress-controller:0.8.3
        name: nginx-ingress-lb
        imagePullPolicy: Always
        readinessProbe:
          httpGet:
            path: /healthz
            port: 10254
            scheme: HTTP
        livenessProbe:
          httpGet:
            path: /healthz
            port: 10254
            scheme: HTTP
          initialDelaySeconds: 10
          timeoutSeconds: 1
        # use downward API
        env:
          - name: POD_NAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: POD_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
        ports:
        - containerPort: 80
          hostPort: 80
        - containerPort: 443
          hostPort: 443
        # we expose 18080 to access nginx stats in url /nginx-status
        # this is optional
        - containerPort: 18080
          hostPort: 18080
        args:
        - /nginx-ingress-controller
        - --default-backend-service=$(POD_NAMESPACE)/default-http-backend
        - --nginx-configmap=$(POD_NAMESPACE)/nginx-ingress-cfg
        - --watch-namespace=production

1 个答案:

答案 0 :(得分:0)

在GKE(Google Kubernetes Engine)上运行时,在创建其中一些资源时可能会遇到“权限被拒绝”错误。这是GKE处理RBAC和IAM权限的方式的细微差别,因此,在运行上述命令之前,应将自己的特权“提升”为“集群管理员”的特权。如果您已经运行了上述命令,则应在提升权限后再次运行它们。

kubectl create clusterrolebinding cluster-admin-binding \
    --clusterrole=cluster-admin \
    --user=$(gcloud config get-value core/account)

尝试点击此命令,然后应用文件