Skip to content

Instantly share code, notes, and snippets.

@xandout
Created March 9, 2022 13:37
Show Gist options
  • Save xandout/c0deda6fa4c3c0169a5fd3f637c64c95 to your computer and use it in GitHub Desktop.
Save xandout/c0deda6fa4c3c0169a5fd3f637c64c95 to your computer and use it in GitHub Desktop.
A bare example of a Deployment, Service and Ingress on Kubernetes
---
apiVersion: v1
kind: Service
metadata:
labels:
kubernetes.io/name: "fun-apache"
name: "fun-apache-svc"
namespace: "{{ namespace }}"
spec:
type: LoadBalancer # NodePort might work for your lab as well.
# If you are using the Ingress below the type should be ClusterIP
ports:
- port: 80 # DO NOT USE 80 IF YOU ALREADY HAVE https://kubernetes.github.io/ingress-nginx/deploy
targetPort: 8080
name: http
selector:
k8s-app: "fun-apache"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: "fun-apache"
namespace: "{{ namespace }}"
spec:
selector:
matchLabels:
k8s-app: "fun-apache"
replicas: 1
template: # template for Pod
metadata:
labels:
k8s-app: "fun-apache"
spec:
containers:
- name: "fun-apache"
image: apache2:1.2.3
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: fun-apache-ingress
namespace: "{{ namespace }}"
spec:
rules:
- host: "yourhost"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: "fun-apache-svc"
port:
number: 80 # Not your pod port, use the k8s Service.Port
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment