Application Deployment Solution
- Create a new deployment in the file
quote.yaml. quote.yamllooks like this:--- apiVersion: apps/v1 kind: Deployment metadata: name: quote-service namespace: development labels: app: quote-service spec: replicas: 2 selector: matchLabels: app: quote-service template: metadata: labels: app: quote-service spec: containers: - name: quote-container image: datawire/quote:0.5.0 ports: - containerPort: 8080- Next challenge is to name the deployment and name the app label as
quote-service.- That would mean setting the name to the following:
metadata: name: quote-service
- That would mean setting the name to the following:
- The app label in this case would be:
labels: app: quote-service - Remember to change that label for all of the
appfields. - Next is to use the
developmentnamespace and that has already been completed here:namespace: development - Next requirement is to change the container name, which is:
spec: containers: - name: quote-container - We want to run two replicas and this is done by:
spec: replicas: 2 - Use the image
datawire, service by Ambassador Labs that generates random quotes.image: datawire/quote:0.5.0 - We then create the pods using
kubectl apply -f quote.yaml - Check
kubectl get pods -n development. - How to use
BusyBoxto check the app works.kubectl exec -it <busybox pod name> -- /bin/sh- Use
wgetto send a request to the pods.- Get the IP addresses with:
kubectl get pods -n development -o widewget <pod ip>:8080- If you get
can't open 'index.html': File exits- Check if the file is already in the busy box environment with
ls - Remove the
index.htmlfile and then run the command again.
- Check if the file is already in the busy box environment with
- If you get
- Get the IP addresses with: