- Development Environment Setup
- Containerize the application
- Push the image to DockerHub
- Configure Kubernetes Cluster on AWS
- Deploy the Kubernetes Dashboard
- Deploy the Application in Kubernetes using .yml file
- Scaling Kubernetes Cluster pods
- Delete the Kubernetes Cluster
Development Environment Setup
- Install AWS CLI
- Install Kubernetes Operations (kops)
Containerize the application
- Clone this repo to a folder
- Open a command prompt and navigate to your project folder.
- Use the following commands to build and run your Docker image:
- View the .Net Core application running from a container by navigating to localhost:8000
Push the image to DockerHub
-
Log in on https://hub.docker.com/
-
Click on Create Repository.
-
Choose a name (e.g. kubeservice) and a description for your repository and click Create.
-
Log into the Docker Hub from the command line
just with your own user name and email that you used for the account. Enter your password when prompted. If everything worked you will get a message similar to
- Check the image ID using
and what you will see will be similar to
- Tag image
- Push image to the repository created in previous steps
Configure Kubernetes Cluster on AWS
-
Login to your AWS console
-
Generate access keys for your user by navigating to Users/Security credentials page
-
Make sure your IAM user has following permissions:
- Make sure to configure the AWS CLI to use your access key ID and secret access key
- Create an S3 bucket for
kops
to use to store the state of the Kubernetes cluster and its configuration
- Enable versioning to revert or recover a previous state store.
- Set the Kubernetes cluster name and S3 bucket URL environment variables
- Generate Kubernetes cluster configuration using kops
- Finally, build the Kubernetes cluster on AWS using following kops command. This might take a few minutes to boot the EC2 instances and download the Kubernetes components.
- Finally, you can see your Kubernetes nodes with kubectl
Deploy the Kubernetes Dashboard
- Deploy the Kubernetes Dashboard by running following command
- Access Dashboard using the kubectl command-line tool by running the following command
- Execute the below command to find the admin service account token
- Click on + CREATE on top right corner of the Kubernetes Dashboad
- Navigate to ‘CREATE FROM FILE’ tab and select the
kubeservice-deploy.yml
file
- Finally, click on UPLOAD button. This will deploy the application and dashboard looks like below once the deployment is completed.
- Access the application using external endpoint listed in Kubernetes – Services Dashboard
Scaling Kubernetes Cluster pods
-
Navigate to Deployments and click on Scale as shown in below screen
-
Finally, dashboard looks like this once the deployment is completed
Delete the Kubernetes Cluster
-
Finally, when you are ready to tear down your Kubernetes cluster, you can delete the cluster using following command