Skip to content

Deploy Application to Kubernetes

This guide provides a step-by-step procedure for deploying or updating applications to the Kubernetes cluster using Helm Charts managed through Rancher.

The deployment process consists of three main steps:

  1. Update application version and ContainerImageTags in the .csproj file
  2. Update Helm Chart versions in the repository
  3. Deploy via Rancher by updating the Helm Chart in Apps

Before beginning deployment:

  • Access to the application source code repository
  • Access to the Helm Chart repository
  • Access to Rancher UI
  • Understanding of semantic versioning (e.g., 1.2.3)

Update the version number in your .NET application’s project file.

Navigate to your application repository and find the project file (e.g., MyService.csproj).

1.2 Update version and ContainerImageTags properties

Section titled “1.2 Update version and ContainerImageTags properties”

Edit the .csproj file and update version-related properties:

<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<ContainerRepository>stable/meter-control-api</ContainerRepository>
<ContainerImageTags>1.17.0</ContainerImageTags>
<OutputPath></OutputPath>
<DocumentationFile>bin/MeterControlApi.xml</DocumentationFile>
</PropertyGroup>
<!-- ... rest of file ... -->
</Project>

Update the following property:

  • <ContainerImageTags> — Docker image version tag (e.g., 1.17.0)
Terminal window
git add MyService.csproj
git commit -m "Bump version to 1.2.3"
git push origin main

If you have automated CI/CD:

  • Wait for build pipeline to complete
  • Verify Docker image is built with new version tag
  • Confirm image is pushed to container registry

Update the Helm Chart to reference the new application version.

Clone or navigate to your Helm Chart repository:

Terminal window
cd /path/to/helm-charts-repo
git pull origin main

Edit the Chart.yaml file in your application’s Helm Chart directory:

apiVersion: v2
name: meter-control-api
description: Meter Control API Chart
type: application
version: 1.0.13
appVersion: "1.17.0"

Update:

  • version — Helm Chart version (increment when chart structure changes, e.g., 1.0.13 → 1.0.14)
  • appVersion — Application version (must match <ContainerImageTags> from .csproj, e.g., “1.17.0”)
Terminal window
git add Chart.yaml values.yaml
git commit -m "Update meter-control-api to version 1.17.0 (chart 1.0.13)"
git push origin main

Update the Helm Chart deployment through Rancher UI.

  1. Navigate to Rancher UI (e.g., https://rancher.inma.kalmarenergi.se)
  2. Log in with your credentials
  3. Select the target cluster
  1. In the left sidebar, click Apps → Installed Apps
  2. Select the namespace where your app is deployed (e.g., production)
  3. Locate your application in the list
  1. Find your application (e.g., my-service)
  2. Click the ⋮ (three-dot menu) on the right
  3. Select Upgrade
  4. In the upgrade dialog:
    • Chart Version: Update to the new Helm Chart version (e.g., 1.5.0)
    • Values: Review and update any values if needed
    • Verify the appVersion or image tag is correct
  5. Click Upgrade to start deployment

Option B: Upgrade via kubectl (alternative)

Section titled “Option B: Upgrade via kubectl (alternative)”

If you prefer command-line deployment:

Terminal window
# Ensure you're in the right context
kubectl config use-context <cluster-name>
# Upgrade the release
helm upgrade my-service ./my-service \
--namespace production \
--values values.yaml \
--wait \
--timeout 10m

In Rancher UI:

  1. Go to Workloads → Pods
  2. Filter by namespace and app name
  3. Watch for pods to transition:
    • Terminating — Old pods shutting down
    • ContainerCreating — New pods starting
    • Running — New pods healthy

Expected sequence:

my-service-7d8f9c-xyz (old) → Terminating
my-service-8e9a0d-abc (new) → ContainerCreating → Running

Check deployment status:

In Rancher UI:

  • Apps → Installed Apps → verify app shows as Deployed
  • Workloads → verify all pods are Running
  • Service Discovery → verify services have healthy endpoints

Via kubectl:

Terminal window
# Check deployment status
kubectl get deployment my-service -n inma
# Check pod status
kubectl get pods -n inma -l app=my-service
# Check rollout status
kubectl rollout status deployment/my-service -n inma
# View recent events
kubectl get events -n inma --sort-by='.lastTimestamp' | grep my-service

Expected output:

NAME READY UP-TO-DATE AVAILABLE AGE
my-service 2/2 2 2 5m

Verify the application is functioning correctly:

Terminal window
# Check pod logs
kubectl logs -n inma deployment/my-service --tail=50
# Check for errors
kubectl logs -n inma deployment/my-service --tail=100 | grep -i error

Test application endpoints:

Terminal window
# Port-forward to test locally (if needed)
kubectl port-forward -n inma svc/my-service 8080:80
# Or test via ingress
curl -I https://my-service.example.com/health

Expected health check response: 200 OK


Check that the new version is running:

Terminal window
# Check image version in pods
kubectl describe pod -n inma -l app=my-service | grep Image:
# Check labels
kubectl get pods -n inma -l app=my-service -o yaml | grep -A 5 labels
  • Check application logs for errors
  • Test critical user flows
  • Monitor error rates and response times

Ensure configuration is correct:

Terminal window
# Check ConfigMaps
kubectl get configmap -n inma | grep my-service
# Check Secrets
kubectl get secrets -n inma | grep my-service
# Verify environment variables
kubectl exec -n inma deployment/my-service -- env | grep APP_

If issues are discovered after deployment:

  1. Go to Apps → Installed Apps
  2. Find your application
  3. Click ⋮ → Rollback
  4. Select the previous revision
  5. Confirm rollback
Terminal window
# View revision history
helm history my-service -n inma
# Rollback to previous version
helm rollback my-service -n inma
# Or rollback to specific revision
helm rollback my-service 5 -n inma
Terminal window
# Rollback deployment
kubectl rollout undo deployment/my-service -n inma
# Check rollback status
kubectl rollout status deployment/my-service -n inma

Check pod status and events:

Terminal window
kubectl describe pod <pod-name> -n inma
kubectl get events -n inma --sort-by='.lastTimestamp'

Common issues:

  • Image pull errors (check registry access and image tag)
  • Resource limits (insufficient CPU/memory)
  • ConfigMap/Secret not found
  • Health probe failures
Terminal window
# Check image name and tag
kubectl describe pod <pod-name> -n inma | grep Image
# Verify image exists in registry
az acr repository show-tags --name myregistry --repository my-service

Solutions:

  • Verify image tag matches appVersion in Helm Chart
  • Check container registry credentials
  • Ensure CI/CD pushed image successfully

Application starting but crashing:

Terminal window
# Check application logs
kubectl logs <pod-name> -n inma --previous
# Check liveness/readiness probes
kubectl describe pod <pod-name> -n inma | grep -A 5 Liveness

Common causes:

  • Application configuration errors
  • Missing environment variables
  • Database connection failures
  • Port conflicts
Terminal window
# Check Helm release status
helm list -n inma
helm status my-service -n inma
# View upgrade history
helm history my-service -n inma

If upgrade is stuck:

Terminal window
# Force upgrade
helm upgrade my-service ./my-service -n inma --force
# Or rollback and try again
helm rollback my-service -n inma

  • Use semantic versioning consistently
  • Tag Git commits with version numbers
  • Keep versions synchronized between .csproj, Chart.yaml, and container images
  • Document breaking changes in release notes
  • Test in staging first before production deployment
  • Use rolling updates to minimize downtime
  • Configure pod disruption budgets for critical apps
  • Set appropriate health checks (liveness, readiness, startup)
  • Monitor during rollout — watch logs and metrics
  • Automated health checks — use Kubernetes probes
  • Smoke tests — run critical tests after deployment
  • Alert on failures — configure monitoring alerts
  • Version control Helm Charts in Git
  • Use Helm repository for chart distribution
  • Document values with comments in values.yaml
  • Keep chart structure clean — use subchart dependencies

  • Update ContainerImageTags property in .csproj file
  • Commit and push application changes
  • Verify CI/CD build completes successfully
  • Update Chart.yaml with new chart and app versions
  • Update values.yaml image tag to match ContainerImageTags
  • Validate Helm Chart with lint and dry-run
  • Commit and push Helm Chart changes
  • Access Rancher UI
  • Navigate to Apps → Installed Apps
  • Upgrade Helm Chart to new version
  • Monitor pod rollout in Rancher
  • Verify all pods are running
  • Check application logs for errors
  • Test application endpoints
  • Verify version deployed correctly
  • Monitor application metrics
  • Document deployment in changelog
  • Notify team of successful deployment