1. apiVersion: apps/v1
    2. kind: Deployment
    3. metadata:
    4. name: nginx
    5. namespace: kube-ops
    6. spec:
    7. replicas: 1
    8. selector:
    9. matchLabels:
    10. app: nginx
    11. template:
    12. metadata:
    13. labels:
    14. app: nginx
    15. spec:
    16. containers:
    17. - name: nginx
    18. image: nginx
    19. imagePullPolicy: IfNotPresent
    20. ports:
    21. - name: web
    22. containerPort: 80
    23. ---
    24. apiVersion: v1
    25. kind: Service
    26. metadata:
    27. name: test-ng
    28. namespace: kube-ops
    29. spec:
    30. selector:
    31. app: nginx
    32. ports:
    33. - name: web
    34. port: 80
    35. ---
    36. apiVersion: v1
    37. kind: Service
    38. metadata:
    39. name: test-ingress
    40. spec:
    41. type: ExternalName
    42. ports:
    43. - name: web
    44. port: 80
    45. externalName: test-ng.kube-ops.svc.cluster.local
    46. ---
    47. apiVersion: extensions/v1beta1
    48. kind: Ingress
    49. metadata:
    50. name: nginx-ingress-demo
    51. annotations:
    52. kubernetes.io/ingress.class: "traefik"
    53. spec:
    54. rules:
    55. - host:
    56. http:
    57. paths:
    58. - backend:
    59. serviceName: test-ingress
    60. servicePort: 80
    61. path: /