In this article I will host website on kubernetes using Groovy script in Jenkins from docker image. Whole process will be fully automated from creating docker image to exposing website to the client. Hence client can access this website from the webserver created.
Dockerfile for creating a webserver
Here mysite.html is my website.
Jenkinsfile for building and pushing image automatically.
Job1: To build and push image to the docker hub.
Create a job ,you must have pipeline plugin installed. Here when you build this job Jenkins will search for Jenkinsfile in Github URL. Then it will build and push the code automatically to the docker hub.
Job DSL plugin for running the Groovy Script:
Create a job and in build section select Job DSLs for running Groovy script.
Job2: Groovy code for copying the code to the server.
Job3: Creating the webserver from the image uploaded in docker hub in job1
Here the website is hosted using the image using Kubernetes and exposed to the client.
Job4: Notify the status of the job3 via email.
YAML file for creating the pods using the image uploaded on docker hub in job1
JOB1 Image build and Push.
JOB2: Copy of code successfull
JOB3: Pods created using image of job1 from docker hub.
Pods created and Exposed.
Client can view my site now.