{"id":1998,"date":"2025-03-16T10:22:23","date_gmt":"2025-03-16T02:22:23","guid":{"rendered":"https:\/\/www.fanyamin.com\/wordpress\/?p=1998"},"modified":"2025-03-16T10:22:23","modified_gmt":"2025-03-16T02:22:23","slug":"helm-tutorial-2","status":"publish","type":"post","link":"https:\/\/www.fanyamin.com\/wordpress\/?p=1998","title":{"rendered":"Helm tutorial 2"},"content":{"rendered":"<p>I have a  Go project that built as a Docker container, let me use a Helm chart to deploy it into the current Kubernetes namespace:<\/p>\n<hr \/>\n<h2><strong>Step 1: Create a Helm Chart<\/strong><\/h2>\n<p>Run the following command to generate a Helm chart structure:<\/p>\n<pre><code class=\"language-sh\">helm create my-go-app<\/code><\/pre>\n<p>This will create a directory named <code>my-go-app<\/code> with the default Helm chart structure.<\/p>\n<hr \/>\n<h2><strong>Step 2: Modify the <code>values.yaml<\/code> File<\/strong><\/h2>\n<p>Navigate to the <code>my-go-app<\/code> directory and edit the <code>values.yaml<\/code> file to define your application\u2019s configuration:<\/p>\n<pre><code class=\"language-yaml\"># values.yaml\nreplicaCount: 1\n\nimage:\n  repository: my-docker-repo\/my-go-app  # Replace with your Docker image repository\n  tag: latest                           # Replace with your desired image tag\n  pullPolicy: IfNotPresent\n\nservice:\n  type: ClusterIP\n  port: 80\n  targetPort: 8080\n\ningress:\n  enabled: false  # Set to true if you want to use Ingress\n\nresources: {}  # Define resource limits if needed\n\nautoscaling:\n  enabled: false\n\nnodeSelector: {}\n\ntolerations: []\n\naffinity: {}<\/code><\/pre>\n<hr \/>\n<h2><strong>Step 3: Update the <code>deployment.yaml<\/code> Template<\/strong><\/h2>\n<p>Modify <code>templates\/deployment.yaml<\/code> to use your Go application\u2019s Docker image:<\/p>\n<pre><code class=\"language-yaml\">apiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  name: {{ .Release.Name }}\nspec:\n  replicas: {{ .Values.replicaCount }}\n  selector:\n    matchLabels:\n      app: {{ .Release.Name }}\n  template:\n    metadata:\n      labels:\n        app: {{ .Release.Name }}\n    spec:\n      containers:\n        - name: my-go-app\n          image: &quot;{{ .Values.image.repository }}:{{ .Values.image.tag }}&quot;\n          imagePullPolicy: {{ .Values.image.pullPolicy }}\n          ports:\n            - containerPort: {{ .Values.service.targetPort }}\n          env:  # Add any environment variables if needed\n            - name: ENV_VAR_NAME\n              value: &quot;your-value&quot;<\/code><\/pre>\n<hr \/>\n<h2><strong>Step 4: Update the <code>service.yaml<\/code> Template<\/strong><\/h2>\n<p>Modify <code>templates\/service.yaml<\/code> to expose your Go application:<\/p>\n<pre><code class=\"language-yaml\">apiVersion: v1\nkind: Service\nmetadata:\n  name: {{ .Release.Name }}\nspec:\n  type: {{ .Values.service.type }}\n  selector:\n    app: {{ .Release.Name }}\n  ports:\n    - protocol: TCP\n      port: {{ .Values.service.port }}\n      targetPort: {{ .Values.service.targetPort }}<\/code><\/pre>\n<hr \/>\n<h2><strong>Step 5: Deploy the Helm Chart<\/strong><\/h2>\n<h3><strong>Set Your Namespace (If Not Already Set)<\/strong><\/h3>\n<p>Ensure you are deploying to the correct namespace:<\/p>\n<pre><code class=\"language-sh\">kubectl config set-context --current --namespace=&lt;your-namespace&gt;<\/code><\/pre>\n<h3><strong>Install the Helm Chart<\/strong><\/h3>\n<p>Run the following command to deploy your Go application:<\/p>\n<pre><code class=\"language-sh\">helm install my-go-app .\/my-go-app<\/code><\/pre>\n<h3><strong>Verify Deployment<\/strong><\/h3>\n<p>Check the status of the pods:<\/p>\n<pre><code class=\"language-sh\">kubectl get pods<\/code><\/pre>\n<p>Check if the service is running:<\/p>\n<pre><code class=\"language-sh\">kubectl get svc<\/code><\/pre>\n<hr \/>\n<h2><strong>Step 6: Upgrade or Uninstall the Helm Release<\/strong><\/h2>\n<h3><strong>Upgrade the Deployment<\/strong><\/h3>\n<p>If you make changes to the chart, upgrade it:<\/p>\n<pre><code class=\"language-sh\">helm upgrade my-go-app .\/my-go-app<\/code><\/pre>\n<h3><strong>Uninstall the Deployment<\/strong><\/h3>\n<p>To remove the application:<\/p>\n<pre><code class=\"language-sh\">helm uninstall my-go-app<\/code><\/pre>\n<hr \/>\n<h2><strong>Next Steps<\/strong><\/h2>\n<ul>\n<li>Add Ingress support if needed.<\/li>\n<li>Enable autoscaling if required.<\/li>\n<li>Configure Persistent Volumes for data storage.<\/li>\n<\/ul>\n<p>Would you like help setting up Ingress or autoscaling? \ud83d\ude80<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a Go project that built as a Docker container, let me use a Helm chart to deploy it into the current Kubernetes namespace: Step 1: Create a Helm Chart Run the following command to generate a Helm chart structure: helm create my-go-app This will create a directory named my-go-app with the default Helm [&hellip;] <a class=\"read-more\" href=\"https:\/\/www.fanyamin.com\/wordpress\/?p=1998\" title=\"Permanent Link to: Helm tutorial 2\">&rarr;Read&nbsp;more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1998","post","type-post","status-publish","format-standard","hentry","category-5"],"_links":{"self":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1998"}],"collection":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1998"}],"version-history":[{"count":1,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1998\/revisions"}],"predecessor-version":[{"id":1999,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1998\/revisions\/1999"}],"wp:attachment":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1998"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1998"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1998"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}