
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx-alpine-ingress
  annotations:
    cert-manager.io/cluster-issuer: "cm-cf"
    kubernetes.io/ingress.class: "traefik"
spec:
  rules:
    - host: as.107421.xyz
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: nginx-alpine-svc
                port:
                  number: 8080
  tls:
    - hosts:
      - as.107421.xyz
      secretName: as.107421.xyz-tls
---
kind: Service
apiVersion: v1
metadata:
  name: nginx-alpine-svc
  namespace: default
spec:
  selector:
    app: nginx-alpine-test
  type: NodePort
  ports:
    - port: 8080
      nodePort: 19500
      targetPort: 80
      name: web-http

---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: nginx-alpine-test
  namespace: default
spec:
  selector:
    matchLabels:
      app: nginx-alpine-test
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx-alpine-test
    spec:
      nodeSelector:
        location: tokyo
      containers:
        - name: nginx-apline
          image: nginx:alpine
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 80
              name: web-http
          env:
            - name: Pod_Name
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: Pod_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
            - name: MY_NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          command:
            - /bin/sh
            - -c
          args:
            - echo "<h2>Pod Name is =${Pod_Name} </h2>" >/usr/share/nginx/html/index.html;
              echo "<h2>Pod IP is = ${Pod_IP} </h2>" >>/usr/share/nginx/html/index.html;
              echo "<h3>The Pod  IP Adrress is = ${Pod_IP} </h3>" >>/usr/share/nginx/html/index.html;
              echo "<h2>Pod is running in Node = ${MY_NODE_NAME} </h2>" >>/usr/share/nginx/html/index.html;
              echo "<h3>Nginx version is = ${NGINX_VERSION} </h3>">>/usr/share/nginx/html/index.html;
              nginx -g "daemon off;";
      volumes:
        - name: nginx-index-html
          emptyDir: {}
