Access
In this part, you will
- Create a K8s YAML workload that will deploy sample application and a service of Type LoadBalancer
- Verify we can access the application via the LoadBalancer
Create Workload YAML¶
We are using a nginx deployment in this example to create a service of type LoadBalancer.
- Copy the K8s YAML manifest below to a file called "nginx-lb.yaml"
- Edit lines 30 to match the name of the IPAddressPool we configured earlier
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: nginx
name: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: nginx
restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
labels:
app: nginx
name: nginx
annotations:
metallb.universe.tf/address-pool: first-pool
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
type: LoadBalancer
Create Workload¶
In this step, we will create a workload based on the YAML from the previous step and publish it to our cluster.
-
Click on Application -> Workloads
-
Click on "Create New Workload" with the name "nginx-lb"
-
Select "K8s YAML" for the Package Type
-
Select "Upload files manually" for Artifact Sync
-
Select the "metallb-system" namespace from the dropdown
-
Click on "CONTINUE"
- Select the file created in the previous step
-
Set the Drift Action to "NotSet"
-
Select a cluster for the placement policy
-
Click on "SAVE AND GO TO PUBLISH"
- Publish the workload
Verify Workload¶
- Click on the Kubectl button on the cluster to open a virtual terminal and run the following kubectl command
kubectl get services -n metallb-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
metallb-webhook-service ClusterIP 10.99.114.3 <none> 443/TCP 22m
nginx LoadBalancer 10.104.43.59 192.168.15.200 80:30245/TCP 83s
- Verify you can securely access the nginx app using your web browser
Recap¶
Congratulations!
You have successfully created a custom cluster blueprint with the "metallb" addon and applied it to a cluster. You can now use this blueprint on as many clusters as you require.