krushnacn / helm-webapp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using the Chart to deploy your Application to Kubernetes

In order to use the Helm chart to deploy and verify your application in Kubernetes, run the following commands:

  1. From the directory containing Chart.yaml, run:

**Helm **

helm install webapp-prod webapp -f frontend/values.yaml

or

helm upgrade --install  webapp-prod webapp -f frontend/values.yaml

This deploys and runs your application in Kubernetes, and prints the following text to the console:

Congratulations, you have deployed your Application to Kubernetes using Helm!

To verify your application is running, run the following two commands to set the POD_NAME and CONTAINER_PORT environment variables to the location of your application:

export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=webapp,app.kubernetes.io/instance=webapp-prod" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT

echo "Visit http://127.0.0.1:8080 to use your application"

And then open your web browser to http://127.0.0.1:8080
  1. Copy, paste and run the export lines printed to the console eg:
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=webapp,app.kubernetes.io/instance=webapp-prod" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
  1. Open a browser to view your application:
    Open your browser to http://127.0.0.1:${CONTAINER_PORT} from the command line using:
open http://127.0.0.1:8080

Your application should now be visible in your browser as

Welcome to python world!

Using the Jenkins to deploy your Application to Kubernetes

Create a Credentials to push docker images to docker hub

Jenkins > Manage jenkins > Manage credentials > Click on Jenkins > Click on Global credentials (unrestricted) > Add Credentials

image

Install Docker pipeline plugin into jenkins

Jenkins > manage jenkins > manage plugins > Click on available > add "Docker Pipeline" in the search bar > select the plugin > Click on install without restart.

Create a pipeline job like below screenshot image

Copy content of jenkins/Jenkinsfile into pipeline section

OR

Jenkinsfile can be mapped to SCM as this is available in GitHub

Please Build the pipeline. Once sucessfully built then it will look like below mentioned screenshot

image

About


Languages

Language:Smarty 84.5%Language:Python 9.0%Language:Dockerfile 6.4%