Helm Deployment To Openshift
Deploying an application to OpenShift using Helm involves several steps. Helm is a package manager for Kubernetes that allows you to define, install, and upgrade even the most complex Kubernetes applications. Below is a guide to deploying an application to OpenShift using Helm.
Prerequisites
-
OpenShift Cluster: Ensure you have access to an OpenShift cluster.
-
Helm: Install Helm on your local machine. You can download it from the official Helm website.
-
ocCLI: Ensure you have theocCLI installed and configured to interact with your OpenShift cluster.
1. Log in to OpenShift
Log in to your OpenShift cluster using the oc CLI:
oc login
2. Create a New Project (Namespace)
Create a new project (namespace) for your Helm deployment:
oc new-project my-helm-project
Replace my-helm-project with the desired name of your project.
3. Ensure Helm is Configured for OpenShift
OpenShift includes some security constraints (SCCs) that may block certain operations during Helm deployment. You can work around this by giving your Helm chart the correct permissions or by using a service account with the necessary privileges.
Option 1: Modify the Security Context in Helm Chart
Modify the Helm chart's templates to include an appropriate security context. For example:
securityContext:
runAsUser: 1001
fsGroup: 1001
Option 2: Use a Predefined Service Account
You can use the anyuid SCC in OpenShift for the service account that Helm uses.
oc adm policy add-scc-to-user anyuid -z default -n my-helm-project
This command allows containers in the project to run as any user ID.
4. Add a Helm Repository
Add a Helm chart repository to your Helm setup. For example, to add the Bitnami repository:
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
5. Install a Helm Chart
You can now install a Helm chart into your OpenShift project. For example, to install a WordPress application:
helm install my-wordpress bitnami/wordpress --namespace my-helm-project
In this command:
-
my-wordpress: The name you want to give your Helm release. -
bitnami/wordpress: The chart you want to install. -
--namespace my-helm-project: Specifies the namespace where the application will be deployed.
6. Monitor the Deployment
Check the status of your Helm release:
helm status my-wordpress -n my-helm-project
To get more details or troubleshoot, you can use:
kubectl get all -n my-helm-project
7. Expose the Application
If your application exposes a service, you may need to create an OpenShift route to access it externally:
oc expose svc/my-wordpress --name=my-wordpress-route -n my-helm-project
Get the route URL:
oc get routes -n my-helm-project
8. Upgrade or Rollback the Deployment
To upgrade your Helm release with new configuration or chart versions:
helm upgrade my-wordpress bitnami/wordpress -n my-helm-project
If something goes wrong, you can roll back to a previous version:
helm rollback my-wordpress 1 -n my-helm-project
9. Uninstall the Helm Chart
When you're done, you can uninstall the Helm chart:
helm uninstall my-wordpress -n my-helm-project
This will delete all the resources associated with the Helm release.
10. Clean Up the Project
If you want to delete the project entirely:
oc delete project my-helm-project
Conclusion
Using Helm with OpenShift allows you to leverage Helm's powerful packaging and templating capabilities while benefiting from OpenShift's enterprise-grade Kubernetes features. Remember to carefully manage security contexts and permissions when deploying Helm charts on OpenShift, as the default constraints may need adjustment.
Connect with me:
-
LinkedIn: https://www.linkedin.com/in/rifaterdemsahin/
-
Twitter: https://x.com/rifaterdemsahin
-
YouTube: https://www.youtube.com/@RifatErdemSahin
Imported from rifaterdemsahin.com · 2025