Reputation: 152
I have 3 VMS running in localsystemeach 1 Master, 2 Nodes. I have installed weave CNI Network. I am trying to install the Nginx ingress controller with
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.44.0/deploy/static/provider/cloud/deploy.yaml
But im unable to create it. I have tried the same with the AWS Ec2 instances. It is always crashing
I have seen the describe
getting this error in admission-create pod MountVolume.SetUp failed for volume "kube-api-access-kdhpc" : object "ingress-nginx"/"kube-root-ca.crt" not registered
and the admission-patch,controller pod is keep on restarting the controller pod output Im kinda struck over here. I have tried using the flannel cni too and the result is the same. Any suggestions are appreciated.
Upvotes: 0
Views: 2117
Reputation: 2672
Try these steps, these configurations worked with me well.
apiVersion: apps/v1
kind: Deployment
metadata:
name: ingress-controller
namespace: ingress-space
spec:
replicas: 1
selector:
matchLabels:
name: nginx-ingress
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
name: nginx-ingress
spec:
containers:
- args:
- /nginx-ingress-controller
- --configmap=$(POD_NAMESPACE)/nginx-configuration
- --default-backend-service=app-space/default-http-backend
env:
- name: POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.21.0
imagePullPolicy: IfNotPresent
name: nginx-ingress-controller
ports:
- containerPort: 80
name: http
protocol: TCP
- containerPort: 443
name: https
protocol: TCP
restartPolicy: Always
serviceAccount: ingress-serviceaccount
serviceAccountName: ingress-serviceaccount
terminationGracePeriodSeconds: 30
Apply this NodePort or LoadBalancer as per your configurations:
apiVersion: v1
kind: Service
metadata:
name: ingress
namespace: ingress-space
spec:
ports:
- name: http
nodePort: 30080
port: 80
protocol: TCP
targetPort: 80
- name: https
nodePort: 31640
port: 443
protocol: TCP
targetPort: 443
selector:
name: nginx-ingress
type: NodePort
You will need to create a service account for the ingress, any name of your choice, apply these rbac Cluster Role and Cluster Role Binding
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: ingress-role
rules:
- apiGroups:
- ""
resources:
- services
- endpoints
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- secrets
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get
- list
- watch
- update
- create
- apiGroups:
- ""
resources:
- pods
verbs:
- list
- watch
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- list
- apiGroups:
- networking.k8s.io
- extensions
resources:
- ingresses
verbs:
- get
- list
- watch
- apiGroups:
- networking.k8s.io
resources:
- ingressclasses
verbs:
- get
- apiGroups:
- networking.k8s.io
- extensions
resources:
- ingresses/status
verbs:
- update
- apiGroups:
- k8s.nginx.org
resources:
- virtualservers
- virtualserverroutes
- globalconfigurations
- transportservers
- policies
verbs:
- list
- watch
- get
- apiGroups:
- k8s.nginx.org
resources:
- virtualservers/status
- virtualserverroutes/status
- policies/status
- transportservers/status
verbs:
- update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: ingress-role-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: ingress-role
subjects:
- kind: ServiceAccount
name: ingress-serviceaccount
namespace: ingress-space
Your ingress source is ready to install, refer to https://kubernetes.io/docs/concepts/services-networking/ingress/ and apply the ingress resource
Upvotes: 1
Reputation: 741
I think you should use this one ( for baremetal )
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-0.31.1/deploy/static/provider/baremetal/deploy.yaml
follow this article :
Nginx Ingress Controller - Failed Calling Webhook
Upvotes: 0