F5 Solutions for Containers > Class 1: Kubernetes with F5 Container Ingress Service > Module 2: CIS Using ClusterIP Mode Source | Edit on
Lab 2.3 - Deploy Hello-World Using ConfigMap w/ AS3¶
Just like the previous lab we’ll deploy the f5-hello-world docker container. But instead of using the Ingress resource we’ll use ConfigMap.
App Deployment¶
On kube-master1 we will create all the required files:
Create a file called
deployment-hello-world.yaml
Tip
Use the file in ~/agilitydocs/docs/class1/kubernetes
deployment-hello-world.yaml¶1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
apiVersion: apps/v1 kind: Deployment metadata: name: f5-hello-world-web namespace: default spec: replicas: 2 selector: matchLabels: app: f5-hello-world-web template: metadata: labels: app: f5-hello-world-web spec: containers: - env: - name: service_name value: f5-hello-world-web image: f5devcentral/f5-hello-world:latest imagePullPolicy: IfNotPresent name: f5-hello-world-web ports: - containerPort: 8080 protocol: TCP
Create a file called
clusterip-service-hello-world.yaml
Tip
Use the file in ~/agilitydocs/docs/class1/kubernetes
clusterip-service-hello-world.yaml¶1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
apiVersion: v1 kind: Service metadata: name: f5-hello-world-web namespace: default labels: app: f5-hello-world-web cis.f5.com/as3-tenant: AS3 cis.f5.com/as3-app: A1 cis.f5.com/as3-pool: web_pool spec: ports: - name: f5-hello-world-web port: 8080 protocol: TCP targetPort: 8080 type: ClusterIP selector: app: f5-hello-world-web
Create a file called
configmap-hello-world.yaml
Tip
Use the file in ~/agilitydocs/docs/class1/kubernetes
configmap-hello-world.yaml¶1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
apiVersion: v1 kind: ConfigMap metadata: name: f5-as3-declaration namespace: default labels: f5type: virtual-server as3: "true" data: template: | { "class": "AS3", "declaration": { "class": "ADC", "schemaVersion": "3.10.0", "id": "urn:uuid:33045210-3ab8-4636-9b2a-c98d22ab915d", "label": "http", "remark": "A1 example", "AS3": { "class": "Tenant", "A1": { "class": "Application", "template": "http", "serviceMain": { "class": "Service_HTTP", "virtualAddresses": [ "10.1.1.4" ], "pool": "web_pool", "virtualPort": 80 }, "web_pool": { "class": "Pool", "monitors": [ "http" ], "members": [ { "servicePort": 8080, "serverAddresses": [] } ] } } } } }
We can now launch our application:
kubectl create -f deployment-hello-world.yaml kubectl create -f clusterip-service-hello-world.yaml kubectl create -f configmap-hello-world.yaml
To check the status of our deployment, you can run the following commands:
kubectl get pods -o wide
kubectl describe svc f5-hello-world
Attention
To understand and test the new app pay attention to the Endpoints value, this shows our 2 instances (defined as replicas in our deployment file) and the flannel IP assigned to the pod.
Now that we have deployed our application sucessfully, we can check the configuration on bigip1. Switch back to the open management session on firefox.
Warning
Don’t forget to select the proper partition. Previously we checked the “kubernetes” partition. In this case we need to look at the “AS3” partition. This partition was auto created by AS3 and named after the Tenant which happens to be “AS3”.
GoTo:
Here you can see a new Virtual Server, “serviceMain” was created, listening on 10.1.1.4:80 in partition “AS3”.
Check the Pools to see a new pool and the associated pool members.
GoTo:
and select the “web_pool” pool. Click the Members tab.Note
You can see that the pool members IP addresses are assigned from the overlay network (ClusterIP mode)
Access your web application via firefox on the jumpbox.
Note
Select the “Hello, World” shortcut or type http://10.1.1.4 in the URL field.
Hit Refresh many times and go back to your BIG-IP UI.
Goto:
to see that traffic is distributed as expected.Note
Why is all the traffic directed to one pool member? The answer can be found by instpecting the “serviceMain” virtual service in the management GUI.
Scale the f5-hello-world app
kubectl scale --replicas=10 deployment/f5-hello-world-web -n default
Check that the pods were created
kubectl get pods
Check the pool was updated on bigip1. GoTo:
and select the “web_pool” pool. Click the Members tab.Attention
Now we show 10 pool members. In Module1 the number stayed at 3 and didn’t change, why?
Remove Hello-World from BIG-IP.
Attention
In older versions of AS3 a “blank AS3 declaration” was required to completely remove the application/declaration from BIG-IP. In AS3 v2.20 and newer this is no longer a requirement.
kubectl delete -f configmap-hello-world.yaml kubectl delete -f clusterip-service-hello-world.yaml kubectl delete -f deployment-hello-world.yaml
Note
Be sure to verify the virtual server and “AS3” partition were removed from BIG-IP.
The next modules are OPTIONAL. If instructed to skip be sure to exit your current SSH session with kube-master1 first. Then click here to start Class 2: OpenShift with Container Ingress Service. Otherwise click “Next” below.
exit