K8s NGINX Deployment for Ingress test

K8s NGINX Deployment for Ingress test

An NGINX container can be quite useful to test whether one's Kubernetes setup is working. Here is one example manifest file that deploys such container with an appropriate service and ingress.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-example
  namespace: example
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx-example
  template:
    metadata:
      labels:
        app: nginx-example
    spec:
      containers:
      - name: nginx-example
        image: nginx
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-example
  namespace: example
spec:
  type: ClusterIP
  selector:
    app: nginx-example
  ports:
  - port: 80
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nginx-example
  namespace: example
  annotations:
    kubernetes.io/ingress.class: "nginx"
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
spec:
  tls:
  - hosts:
    - YOUR_DOMAIN
    secretName: nginx-example
  rules:
  - host: YOUR_DOMAIN
    http:
      paths:
      - path: /
        backend:
          serviceName: nginx-example
          servicePort: 80