Last active
October 19, 2021 01:29
-
-
Save chukaofili/d0a6713734d0953ce1ce667958464edb to your computer and use it in GitHub Desktop.
Echo Server Deployment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Namespace | |
metadata: | |
name: echoserver | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: echoserver | |
namespace: echoserver | |
spec: | |
replicas: 3 | |
template: | |
metadata: | |
labels: | |
app: echoserver | |
spec: | |
containers: | |
- image: gcr.io/google_containers/echoserver:1.0 | |
imagePullPolicy: Always | |
name: echoserver | |
ports: | |
- containerPort: 8080 | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: echoserver | |
namespace: echoserver | |
spec: | |
ports: | |
- port: 80 | |
targetPort: 8080 | |
protocol: TCP | |
selector: | |
app: echoserver | |
--- | |
apiVersion: extensions/v1beta1 | |
kind: Ingress | |
metadata: | |
name: echoserver | |
namespace: echoserver | |
annotations: | |
kubernetes.io/ingress.class: "nginx" | |
spec: | |
rules: | |
- host: echo.example.com | |
http: | |
paths: | |
- path: / | |
backend: | |
serviceName: echoserver | |
servicePort: 80 |
Need to change
apiVersion: extensions/v1beta1
to
apiVersion: apps/v1
apiVersion: apps/v1
kind: Deployment
metadata:
name: echoserver
spec:
replicas: 3
selector:
matchLabels:
app: echoserver
template:
metadata:
labels:
app: echoserver
spec:
containers:
- image: gcr.io/google_containers/echoserver:1.0
imagePullPolicy: Always
name: echoserver
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: echoserver
spec:
ports:
- port: 80
targetPort: 8080
protocol: TCP
selector:
app: echoserver
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: echoserver
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- host: echo.example.com
http:
paths:
- path: /
backend:
serviceName: echoserver
servicePort: 80
FYI, I also had to add
selector:
matchLabels:
app: echoserver
on a Kubernetes 1.18 cluster.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doesn't work with Kubernetes 1.16+. see https://gist.github.com/roock/26e915450dfcac2a70ed6e44e0c75cde for a working version with Kubernetes 1.16