Refer to Exhibit.Set Configuration Context:[student@node-1] $ | kubectlConfig use-context k8sContextA container within the poller pod is hard-coded to connect the nginxsvc service on port 90 . As this port changes to 5050 an additional container needs to be added to the poller pod which adapts the container to connect to this new port. This should be realized as an ambassador container within the pod.Task* Update the nginxsvc service to serve on port 5050.* Add an HAproxy container named haproxy bound to port 90 to the poller pod and deploy the enhanced pod. Use the image haproxy and inject the configuration located at /opt/KDMC00101/haproxy.cfg, with a ConfigMap named haproxy-config, mounted into the container so that haproxy.cfg is available at /usr/local/etc/haproxy/haproxy.cfg. Ensure that you update the args of the poller container to connect to localhost instead of nginxsvc so that the connection is correctly proxied to the new service endpoint. You must not modify the port of the endpoint in poller's args . The spec file used to create the initial poller pod is available in /opt/KDMC00101/poller.yaml
A) Explanation:
Solution:
To update the nginxsvc service to serve on port 5050, you will need to edit the service's definition yaml file. You can use the kubectl edit command to edit the service in place.
kubectl edit svc nginxsvc
This will open the service definition yaml file in your default editor. Change the targetPort of the service to 5050 and save the file.
To add an HAproxy container named haproxy bound to port 90 to the poller pod, you will need to edit the pod's definition yaml file located at /opt/KDMC00101/poller.yaml.
You can add a new container to the pod's definition yaml file, with the following configuration:
containers:
- name: haproxy
image: haproxy
ports:
- containerPort: 90
volumeMounts:
- name: haproxy-config
mountPath: /usr/local/etc/haproxy/haproxy.cfg
subPath: haproxy.cfg
args: ['haproxy', '-f', '/usr/local/etc/haproxy/haproxy.cfg']
This will add the HAproxy container to the pod and configure it to listen on port 90. It will also mount the ConfigMap haproxy-config to the container, so that haproxy.cfg is available at /usr/local/etc/haproxy/haproxy.cfg.
To inject the configuration located at /opt/KDMC00101/haproxy.cfg to the container, you will need to create a ConfigMap using the following command:
kubectl create configmap haproxy-config --from-file=/opt/KDMC00101/haproxy.cfg
You will also need to update the args of the poller container so that it connects to localhost instead of nginxsvc. You can do this by editing the pod's definition yaml file and changing the args field to args: ['poller','--host=localhost'].
Once you have made these changes, you can deploy the updated pod to the cluster by running the following command:
kubectl apply -f /opt/KDMC00101/poller.yaml
This will deploy the enhanced pod with the HAproxy container to the cluster. The HAproxy container will listen on port 90 and proxy connections to the nginxsvc service on port 5050. The poller container will connect to localhost instead of nginxsvc, so that the connection is correctly proxied to the new service endpoint.
Please note that, this is a basic example and you may need to tweak the haproxy.cfg file and the args based on your use case.
Alishia
7 months agoGabriele
7 months agoMan
7 months agoTayna
8 months agoElmer
8 months agoGussie
8 months agoAmber
8 months agoPaulene
8 months agoWeldon
8 months agoTracie
8 months agoNu
8 months agoHoward
8 months agoRolland
9 months agoLoren
9 months agoAshlee
9 months agoArminda
9 months agoSheridan
9 months agoLeanora
1 year agoAlberta
1 year agoTran
1 year agoArlene
1 year agoEarleen
1 year agoCelestina
1 year agoRosendo
1 year agoKeva
1 year agoOzell
1 year agoBreana
1 year agoMarjory
1 year agoJustine
1 year agoSherell
1 year agoElroy
1 year agoCatalina
1 year agoKyoko
1 year agoElroy
1 year agoJoanna
1 year agoSylvie
1 year agoEladia
1 year agoSage
1 year agoJeff
1 year agoSage
1 year agoSage
1 year agoSage
1 year ago