{"id":282,"date":"2023-05-01T07:31:07","date_gmt":"2023-05-01T07:31:07","guid":{"rendered":"https:\/\/keyshell.net\/blog\/?p=282"},"modified":"2023-05-01T07:31:07","modified_gmt":"2023-05-01T07:31:07","slug":"deploying-a-spring-boot-microservice-using-helm-charts","status":"publish","type":"post","link":"https:\/\/keyshell.net\/blog\/2023\/05\/01\/deploying-a-spring-boot-microservice-using-helm-charts\/","title":{"rendered":"Deploying a Spring Boot microservice using Helm charts"},"content":{"rendered":"<p>In this blog,we explain the steps to deploy a Spring Boot microservice using Helm Charts.First we will build a docker image using a Docker file.This docker image is pushed to a repository.Then we will use Helm Charts to deploy our application to a Kubernetes cluster.An Nginx Ingress Controller is configured to expose our application to the outside world and manage traffic flow in a more flexible and scalable way.<\/p>\n<p>Java Spring Boot is an open-source tool that makes it easier to use Java-based frameworks to create microservices and web apps.<\/p>\n<p>Managing kubernetes cluster consists of checking cluster, pods, nodes, application deployment, replicas, load-balancer etc is a hectic task.So inorder to manage a Kubernetes cluster more efficiently and easily, one can use a package manager like Helm. Helm provides several advantages for managing Kubernetes applications,including:<\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Simplified Deployment:<\/strong> With Helm, you can easily package and deploy complex applications with a single command, reducing the need for manual configuration and deployment steps.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><strong>Version Control:<\/strong> Helm allows you to manage and track the version history of your Kubernetes applications, making it easier to roll back to previous versions in case of issues or bugs.<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><strong>Modular Architecture:<\/strong> Helm uses a modular architecture that allows you to break down your applications into smaller, reusable components that can be easily deployed and managed.<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">Overall, Helm provides a powerful and flexible solution for managing Kubernetes applications, making it easier to deploy, manage, and scale complex applications on Kubernetes clusters.<\/span><\/p>\n<p><b><i>Prerequisites:<\/i><\/b><b><i><br \/>\n<\/i><\/b><i><span style=\"font-weight: 400;\">Docker Instance : To build the spring boot docker image and push to repository<\/span><\/i><\/p>\n<p><i><span style=\"font-weight: 400;\">Docker Hub Account\/Any other Repository service for Docker Images<\/span><\/i><\/p>\n<p><i><span style=\"font-weight: 400;\">Basic Git Commands<\/span><\/i><\/p>\n<p><i><span style=\"font-weight: 400;\">Kubernetes Cluster: We used AWS\u2019s EKS cluster.Bastion Host configured to manage K8\u2019s.<\/span><\/i><\/p>\n<p><span style=\"font-weight: 400;\">First,let&#8217;s login to Docker Instance and build a docker image for our sample spring boot application.Clone the Sample Spring Boot Application : <\/span><a href=\"https:\/\/github.com\/Keyshelltechs\/sample_spring_boot\"><span style=\"font-weight: 400;\">https:\/\/github.com\/Keyshelltechs\/sample_spring_boot<\/span><\/a><\/p>\n<p><i><span style=\"font-weight: 400;\">DockerFile<\/span><\/i><\/p>\n<pre><code><span style=\"font-weight: 400;\">FROM<\/span><span style=\"font-weight: 400;\"> maven:3.8.5-openjdk-18-slim <\/span><span style=\"font-weight: 400;\">AS<\/span><span style=\"font-weight: 400;\"> build<\/span>\r\n\r\n<span style=\"font-weight: 400;\">WORKDIR<\/span><span style=\"font-weight: 400;\"> \/usr\/src\/app<\/span>\r\n\r\n<span style=\"font-weight: 400;\">COPY<\/span><span style=\"font-weight: 400;\"> . \/usr\/src\/app<\/span>\r\n\r\n<span style=\"font-weight: 400;\">RUN<\/span><span style=\"font-weight: 400;\"> mvn package<\/span>\r\n\r\n<span style=\"font-weight: 400;\">FROM<\/span><span style=\"font-weight: 400;\"> openjdk:18-jdk-slim<\/span>\r\n\r\n<span style=\"font-weight: 400;\">EXPOSE<\/span><span style=\"font-weight: 400;\"> 8080<\/span>\r\n\r\n<span style=\"font-weight: 400;\">ARG<\/span><span style=\"font-weight: 400;\"> JAR_FILE=spring-boot-ecs.jar<\/span>\r\n\r\n<span style=\"font-weight: 400;\">WORKDIR<\/span><span style=\"font-weight: 400;\"> \/opt\/app<\/span>\r\n\r\n<span style=\"font-weight: 400;\">COPY<\/span><span style=\"font-weight: 400;\"> --from=build \/usr\/src\/app\/target\/${JAR_FILE} \/opt\/app\/<\/span>\r\n\r\n<span style=\"font-weight: 400;\">ENTRYPOINT<\/span><span style=\"font-weight: 400;\"> [<\/span><span style=\"font-weight: 400;\">\"java\"<\/span><span style=\"font-weight: 400;\">,<\/span><span style=\"font-weight: 400;\">\"-jar\"<\/span><span style=\"font-weight: 400;\">,<\/span><span style=\"font-weight: 400;\">\"spring-boot-ecs.jar\"<\/span><span style=\"font-weight: 400;\">]<\/span><\/code> <span style=\"font-weight: 400;\">In this Dockerfile we use Multi-Stage build for creating a jar file in the first build and copying that jar file in the second build.<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Let\u2019s login to our Docker Hub Account.<\/span><\/p>\n<blockquote><p><em>$ docker login<\/em><\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">Now let\u2019s build the docker image using the docker command:<\/span><\/p>\n<blockquote><p><em><span style=\"font-weight: 400;\">$ <\/span><span style=\"font-weight: 400;\">docker<\/span> <span style=\"font-weight: 400;\">build<\/span> <span style=\"font-weight: 400;\">-t<\/span> <span style=\"font-weight: 400;\">keyshelltechs\/sample_spring_boot:latest<\/span> <span style=\"font-weight: 400;\">.<\/span><\/em><\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">Here \u2018keyshelltechs\u2019 is my dockerhub\u2019s username and \u2018sample_spring_boot\u2019 is the repository name and \u2018latest\u2019 is the tag.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Now let\u2019s push this image to our Docker Hub repository using this command:<\/span><\/p>\n<blockquote><p><em><span style=\"font-weight: 400;\">$ <\/span><span style=\"font-weight: 400;\">docker<\/span> <span style=\"font-weight: 400;\">push<\/span> <span style=\"font-weight: 400;\">keyshelltechs\/sample_spring_boot:latest<\/span><\/em><\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">Now let\u2019s install Helm in our Bastion Host.I\u2019m using Amazon Linux 2 for my Bastion Host.<\/span><\/p>\n<blockquote><p><em><span style=\"font-weight: 400;\">$ <\/span><span style=\"font-weight: 400;\">curl<\/span> <span style=\"font-weight: 400;\">https:\/\/raw.githubusercontent.com\/helm\/helm\/master\/scripts\/get-helm-3<\/span><span style=\"font-weight: 400;\"> &gt; <\/span><span style=\"font-weight: 400;\">get_helm.sh<\/span><\/em><\/p>\n<p><em><span style=\"font-weight: 400;\">$ <\/span><span style=\"font-weight: 400;\">chmod<\/span> <span style=\"font-weight: 400;\">700<\/span> <span style=\"font-weight: 400;\">get_helm.sh<\/span><\/em><\/p>\n<p><em><span style=\"font-weight: 400;\">$ <\/span><span style=\"font-weight: 400;\">.\/get_helm.sh<\/span><\/em><\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">You can refer to this link for helm installation : <\/span><a href=\"https:\/\/docs.aws.amazon.com\/eks\/latest\/userguide\/helm.html\"><span style=\"font-weight: 400;\">https:\/\/docs.aws.amazon.com\/eks\/latest\/userguide\/helm.html<\/span><\/a><\/p>\n<p><span style=\"font-weight: 400;\">To check helm version : <\/span><b>$ helm version<\/b><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">After the helm is installed,let\u2019s install <\/span><b>Ingress Controller <\/b><span style=\"font-weight: 400;\">using Helm charts.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">For that, first we have to add the Helm Repository :<\/span><\/p>\n<blockquote><p><em><span style=\"font-weight: 400;\">$ <\/span><span style=\"font-weight: 400;\">helm<\/span> <span style=\"font-weight: 400;\">repo<\/span> <span style=\"font-weight: 400;\">add<\/span> <span style=\"font-weight: 400;\">nginx-stable<\/span> <span style=\"font-weight: 400;\">https:\/\/helm.nginx.com\/stable<\/span><\/em><\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">Now update the repository for ensuring that you have access to the latest versions of Helm charts and managing the repositories from which you install charts.\u00a0<\/span><\/p>\n<blockquote><p><em><span style=\"font-weight: 400;\">$ <\/span><span style=\"font-weight: 400;\">helm<\/span> <span style=\"font-weight: 400;\">repo<\/span> <span style=\"font-weight: 400;\">update<\/span><\/em><\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">Now let\u2019s install the chart from the repository:<\/span><\/p>\n<blockquote><p><em><span style=\"font-weight: 400;\">$ <\/span><span style=\"font-weight: 400;\">helm<\/span> <span style=\"font-weight: 400;\">install<\/span> <span style=\"font-weight: 400;\">my-release<\/span> <span style=\"font-weight: 400;\">nginx-stable\/nginx-ingress<\/span><\/em><\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">You can refer to this link for Ingress Controller installation :<\/span><\/p>\n<p><a href=\"https:\/\/docs.nginx.com\/nginx-ingress-controller\/installation\/installation-with-helm\"><span style=\"font-weight: 400;\">https:\/\/docs.nginx.com\/nginx-ingress-controller\/installation\/installation-with-helm<\/span><\/a><\/p>\n<p><span style=\"font-weight: 400;\">Now let\u2019s check whether this ingress controller is working or not.<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">For that, let&#8217;s check our K8\u2019s pods and services.<\/span><\/p>\n<blockquote><p><em><span style=\"font-weight: 400;\">$ <\/span><span style=\"font-weight: 400;\">kubectl<\/span> <span style=\"font-weight: 400;\">get<\/span> <span style=\"font-weight: 400;\">pods<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">$ <\/span><span style=\"font-weight: 400;\">kubectl<\/span> <span style=\"font-weight: 400;\">get<\/span> <span style=\"font-weight: 400;\">svc<\/span><\/em><\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">We can get the <\/span><b>External IP<\/b><span style=\"font-weight: 400;\"> of our ingress controller from <\/span><em><span style=\"font-weight: 400;\">$ <\/span><span style=\"font-weight: 400;\">kubectl<\/span> <span style=\"font-weight: 400;\">get<\/span> <span style=\"font-weight: 400;\">svc<\/span><\/em><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Now,let\u2019s create the helm chart for our spring boot application.<\/span><\/p>\n<blockquote><p><em><span style=\"font-weight: 400;\">$ <\/span><span style=\"font-weight: 400;\">helm<\/span> <span style=\"font-weight: 400;\">create<\/span> <span style=\"font-weight: 400;\">springboot<\/span><\/em><\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">Here \u201cspringboot\u201d is custom name given by us.This will create basic Helm Chart skeleton with the name springboot.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Run the following command to see the tree structure of our Springboot Helm Chart:<\/span><\/p>\n<blockquote><p><em><span style=\"font-weight: 400;\">$ <\/span><span style=\"font-weight: 400;\">tree<\/span> <span style=\"font-weight: 400;\">springboot<\/span><\/em><\/p><\/blockquote>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"my-custom-class\" src=\"https:\/\/keyshell.net\/blog\/wp-content\/uploads\/2023\/05\/Screenshot-from-2023-04-25-19-33-32.png\" alt=\"\" width=\"510\" height=\"273\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Of these files,we have to edit <\/span><b>Chart.yaml<\/b><span style=\"font-weight: 400;\">,<\/span><b>values.yaml<\/b><span style=\"font-weight: 400;\"> &amp; <\/span><b>deployment.yaml<\/b><\/p>\n<p><span style=\"text-decoration: underline;\"><b>Chart.yaml<\/b><\/span><\/p>\n<pre><code><span style=\"font-weight: 400;\">apiVersion: v2<\/span>\r\n\r\n<span style=\"font-weight: 400;\">name: springboot<\/span>\r\n\r\n<span style=\"font-weight: 400;\">description: A Helm chart for Kubernetes<\/span>\r\n\r\n<span style=\"font-weight: 400;\">type: application<\/span>\r\n\r\n<span style=\"font-weight: 400;\">version: 0.1.0<\/span>\r\n\r\n<span style=\"font-weight: 400;\">appVersion: \"latest\"<\/span><\/code><\/pre>\n<p><span style=\"font-weight: 400;\">Here keep in mind that <\/span><b>\u201cappVersion\u201d <\/b><span style=\"font-weight: 400;\">should be the tag which you are using for the Docker image.<\/span><\/p>\n<p><span style=\"text-decoration: underline;\"><b>values.yaml<\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\">In a Helm chart, values.yaml is a file that allows users to customize the deployment of the chart. It contains a set of key-value pairs that define the configuration settings for the chart. These values can be used to override the default configuration settings defined in the chart&#8217;s templates.<\/span><\/p>\n<pre><code><span style=\"font-weight: 400;\">replicaCount<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">3<\/span>\r\n\r\n<span style=\"font-weight: 400;\">image<\/span><span style=\"font-weight: 400;\">:<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">repository<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">keyshelltechs\/sample_spring_boot<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">pullPolicy<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">Always<\/span>\r\n\r\n<span style=\"font-weight: 400;\">imagePullSecrets<\/span><span style=\"font-weight: 400;\">: []<\/span>\r\n\r\n<span style=\"font-weight: 400;\">nameOverride<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">\"\"<\/span>\r\n\r\n<span style=\"font-weight: 400;\">fullnameOverride<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">\"springboot\"<\/span>\r\n\r\n<span style=\"font-weight: 400;\">serviceAccount<\/span><span style=\"font-weight: 400;\">:\u00a0<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">create<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">true<\/span><span style=\"font-weight: 400;\">\u00a0<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">name<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">\"springboot\"<\/span>\r\n\r\n<span style=\"font-weight: 400;\">podAnnotations<\/span><span style=\"font-weight: 400;\">: {}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">podSecurityContext<\/span><span style=\"font-weight: 400;\">: {}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">securityContext<\/span><span style=\"font-weight: 400;\">: {}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">service<\/span><span style=\"font-weight: 400;\">:<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">type<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">ClusterIP<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">port<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">80<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">targetPort<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">8080<\/span>\r\n\r\n<span style=\"font-weight: 400;\">ingress<\/span><span style=\"font-weight: 400;\">:<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">enabled<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">true<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">annotations<\/span><span style=\"font-weight: 400;\">:<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">kubernetes.io\/ingress.class<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">nginx<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">kubernetes.io\/tls-acme<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">\"true\"<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">hosts<\/span><span style=\"font-weight: 400;\">:<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0- <\/span><span style=\"font-weight: 400;\">host<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">External_IP_of_ingress_controller<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">paths<\/span><span style=\"font-weight: 400;\">:<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0- <\/span><span style=\"font-weight: 400;\">path<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">\/<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">pathType<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">Prefix<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">backend<\/span><span style=\"font-weight: 400;\">:<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">serviceName<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">springboot-starterkit-svc<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">servicePort<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">80<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">tls<\/span><span style=\"font-weight: 400;\">: []<\/span>\r\n\r\n<span style=\"font-weight: 400;\">resources<\/span><span style=\"font-weight: 400;\">: {}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">autoscaling<\/span><span style=\"font-weight: 400;\">:<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">enabled<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">false<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">minReplicas<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">1<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">maxReplicas<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">100<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">targetCPUUtilizationPercentage<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">80<\/span>\r\n\r\n<span style=\"font-weight: 400;\">nodeSelector<\/span><span style=\"font-weight: 400;\">: {}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">tolerations<\/span><span style=\"font-weight: 400;\">: []<\/span>\r\n\r\n<span style=\"font-weight: 400;\">affinity<\/span><span style=\"font-weight: 400;\">: {}<\/span><\/code><\/pre>\n<p><span style=\"font-weight: 400;\">Image\u2019s repository value as\u00a0 <\/span><b>keyshelltechs\/sample_spring_boot <\/b><span style=\"font-weight: 400;\">(without tag) which is the name of the image we have pushed earlier.Tag for this image is mentioned in <\/span><b>Chart.yaml<\/b><span style=\"font-weight: 400;\"> file.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Ingress is enabled here and we should replace <\/span><b>External_IP_of_ingress_controller <\/b><span style=\"font-weight: 400;\">with <\/span><b>External IP<\/b><span style=\"font-weight: 400;\"> of our ingress controller which we have obtained in the earlier step.<\/span><\/p>\n<p><span style=\"text-decoration: underline;\"><b>deployment.yaml<\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\">In a Helm chart, deployment.yaml is a file that defines the Kubernetes Deployment resource used to manage the deployment of an application.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The deployment.yaml file defines the desired state of the Kubernetes Deployment resource. It specifies the containers and other resources that make up the application.This file can be customized using the values provided in the values.yaml file to enable parameterized deployment.<\/span><\/p>\n<pre><code><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">containers<\/span><span style=\"font-weight: 400;\">:<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0- <\/span><span style=\"font-weight: 400;\">name<\/span><span style=\"font-weight: 400;\">: {{ <\/span><span style=\"font-weight: 400;\">.Chart.Name<\/span><span style=\"font-weight: 400;\"> }}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">securityContext<\/span><span style=\"font-weight: 400;\">:<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{{- <\/span><span style=\"font-weight: 400;\">toYaml .Values.securityContext | nindent 12<\/span><span style=\"font-weight: 400;\"> }}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">image<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">\"{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}\"<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">imagePullPolicy<\/span><span style=\"font-weight: 400;\">: {{ <\/span><span style=\"font-weight: 400;\">.Values.image.pullPolicy<\/span><span style=\"font-weight: 400;\"> }}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">ports<\/span><span style=\"font-weight: 400;\">:<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0- <\/span><span style=\"font-weight: 400;\">name<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">http<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">containerPort<\/span><span style=\"font-weight: 400;\">: {{ <\/span><span style=\"font-weight: 400;\">.Values.service.targetPort<\/span><span style=\"font-weight: 400;\"> }}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">protocol<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">TCP<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">livenessProbe<\/span><span style=\"font-weight: 400;\">:<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">httpGet<\/span><span style=\"font-weight: 400;\">:<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">path<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">\/<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">port<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">http<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">readinessProbe<\/span><span style=\"font-weight: 400;\">:<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">httpGet<\/span><span style=\"font-weight: 400;\">:<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">path<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">\/<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">port<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">http<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">resources<\/span><span style=\"font-weight: 400;\">:<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{{- <\/span><span style=\"font-weight: 400;\">toYaml .Values.resources | nindent 12<\/span><span style=\"font-weight: 400;\"> }}<\/span><\/code><\/pre>\n<p><span style=\"font-weight: 400;\">In this file we have only edited the <\/span><b>container: <\/b><span style=\"font-weight: 400;\">portion.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Now let\u2019s run the install command.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Make sure you are in the parent directory of our <\/span><b>\u2018springboot\u2019<\/b><span style=\"font-weight: 400;\"> folder to run this command.<\/span><\/p>\n<blockquote><p><em><span style=\"font-weight: 400;\">$ <\/span><span style=\"font-weight: 400;\">helm<\/span> <span style=\"font-weight: 400;\">install<\/span> <span style=\"font-weight: 400;\">your-release-name<\/span> <span style=\"font-weight: 400;\">springboot<\/span><\/em><\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">Here you can give your custom release name instead of <\/span><b>\u2018your-release-name\u2019<\/b><span style=\"font-weight: 400;\"> and <\/span><b>\u2018springboot\u2019 <\/b><span style=\"font-weight: 400;\">is our folder which was created during the earlier step.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If everything goes right we can see release notes of the helm deployment.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"my-custom-class\" src=\"https:\/\/keyshell.net\/blog\/wp-content\/uploads\/2023\/05\/Screenshot-from-2023-04-28-23-27-12.png\" alt=\"\" width=\"762\" height=\"198\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Also check all our pods are running by :<\/span><\/p>\n<blockquote><p><em><span style=\"font-weight: 400;\">$ <\/span><span style=\"font-weight: 400;\">kubectl<\/span> <span style=\"font-weight: 400;\">get<\/span> <span style=\"font-weight: 400;\">pods<\/span><\/em><\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">We can access our site through this URL.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"my-custom-class\" src=\"https:\/\/keyshell.net\/blog\/wp-content\/uploads\/2023\/05\/Screenshot-from-2023-04-28-23-28-54.png\" alt=\"\" width=\"1847\" height=\"971\" \/><\/p>\n<p><span style=\"font-weight: 400;\">You can also refer our repo by :<\/span><\/p>\n<blockquote><p><span style=\"font-weight: 400;\"><em>$ helm repo add keyshell http:\/\/keyshelltechs.github.io\/sample_helm_charts\/charts<\/em><br \/>\n<\/span><\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">(github link : <\/span><a href=\"https:\/\/github.com\/Keyshelltechs\/sample_helm_charts\"><span style=\"font-weight: 400;\">https:\/\/github.com\/Keyshelltechs\/sample_helm_charts<\/span><\/a><span style=\"font-weight: 400;\">)<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">To fetch the chart use:<\/span><\/p>\n<blockquote><p><em><span style=\"font-weight: 400;\">$ helm <\/span><span style=\"font-weight: 400;\">fetch<\/span> <span style=\"font-weight: 400;\">keyshell\/springboot<\/span><\/em><\/p>\n<p>&nbsp;<\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">Thanks for reading. Happy Helming.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If you have any queries contact us at \ud83d\udcf2 +91-81295 71359 or email us at support@keyshell.net<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog,we explain the steps to deploy a Spring Boot microservice using Helm Charts.First we will build a docker image using a Docker file.This docker image is pushed to a repository.Then we will use Helm Charts to deploy our application to a Kubernetes cluster.An Nginx Ingress Controller is configured to expose our application to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"pagelayer_contact_templates":[],"_pagelayer_content":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-282","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/keyshell.net\/blog\/wp-json\/wp\/v2\/posts\/282","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/keyshell.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/keyshell.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/keyshell.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/keyshell.net\/blog\/wp-json\/wp\/v2\/comments?post=282"}],"version-history":[{"count":33,"href":"https:\/\/keyshell.net\/blog\/wp-json\/wp\/v2\/posts\/282\/revisions"}],"predecessor-version":[{"id":319,"href":"https:\/\/keyshell.net\/blog\/wp-json\/wp\/v2\/posts\/282\/revisions\/319"}],"wp:attachment":[{"href":"https:\/\/keyshell.net\/blog\/wp-json\/wp\/v2\/media?parent=282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/keyshell.net\/blog\/wp-json\/wp\/v2\/categories?post=282"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/keyshell.net\/blog\/wp-json\/wp\/v2\/tags?post=282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}