Now that our Armory Application and Kubernetes Namespaces are created, we’re going to set up some load balancers.
For each of our environments, we’re going to set up two Kubernetes resources:
To learn more about Ingress, and why its important, check out the Kubernetes documentation.
Armory abstracts both Kubernetes Service and Kubernetes Ingress objects as Armory “Load Balancer” objects, so we’ll be creating six total Armory “Load Balancers” (one Ingress and one Service for each of our three Namespaces).
apiVersion: v1
kind: Namespace
metadata:
name: dev
---
apiVersion: v1
kind: Service
metadata:
name: hello-today
namespace: dev
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
selector:
lb: hello-today
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
traefik.ingress.kubernetes.io/rule-type: PathPrefixStrip
nginx.ingress.kubernetes.io/rewrite-target: /
labels:
app: hello-today
name: hello-today
namespace: dev
spec:
rules:
- http:
paths:
- backend:
serviceName: hello-today
servicePort: http
path: /dev/hello-today
apiVersion: v1
kind: Namespace
metadata:
name: staging
---
apiVersion: v1
kind: Service
metadata:
name: hello-today
namespace: staging
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
selector:
lb: hello-today
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
traefik.ingress.kubernetes.io/rule-type: PathPrefixStrip
nginx.ingress.kubernetes.io/rewrite-target: /
labels:
app: hello-today
name: hello-today
namespace: staging
spec:
rules:
- http:
paths:
- backend:
serviceName: hello-today
servicePort: http
path: /staging/hello-today
apiVersion: v1
kind: Namespace
metadata:
name: prod
---
apiVersion: v1
kind: Service
metadata:
name: hello-today
namespace: prod
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
selector:
lb: hello-today
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
traefik.ingress.kubernetes.io/rule-type: PathPrefixStrip
nginx.ingress.kubernetes.io/rewrite-target: /
labels:
app: hello-today
name: hello-today
namespace: prod
spec:
rules:
- http:
paths:
- backend:
serviceName: hello-today
servicePort: http
path: /prod/hello-today
It takes a few seconds to finalize manifest deployment. Refresh the page and you should now have six items on the “Load Balancers” page. You also can create all six resources at once, or one at a time instead of two at a time via configuration above.
Creation of the Service and Ingress could also occur through a Deploy (Manifest) pipeline stage that has the Service and Ingress resource manifests in it.