skip to content
Alvin Lucillo

Apply helm on existing resources

/ 2 min read

If there are existing k8s resources deployed using manifests, you can deploy new resources using helm chart. This means the resources can coexist regardless of how they were created, manually or via helm chart.

Let’s say we have a deployment and service manifests. These are already running in minikube.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: raw-app
  namespace: demo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: raw-app
  template:
    metadata:
      labels:
        app: raw-app
    spec:
      containers:
        - name: nginx
          image: nginx:1.25
          ports:
            - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: raw-app
  namespace: demo
spec:
  selector:
    app: raw-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80

With helm create chart-hello, we have a new helm chart:

├── chart-hello
│   ├── Chart.yaml
│   ├── charts
│   ├── templates
│   │   ├── NOTES.txt
│   │   ├── _helpers.tpl
│   │   ├── deployment.yaml
│   │   ├── hpa.yaml
│   │   ├── ingress.yaml
│   │   ├── service.yaml
│   │   ├── serviceaccount.yaml
│   │   └── tests
│   │       └── test-connection.yaml
│   └── values.yaml

If we install the helm chart, there should be no errors: helm install hello-release ./chart-hello --namespace demo

Below, raw-app and hello-release exist in the same namespace.

k get all
NAME                                             READY   STATUS             RESTARTS          AGE
pod/hello-release-chart-hello-65b6bd8568-l9wl6   0/1     CrashLoopBackOff   109 (2m20s ago)   7h1m
pod/raw-app-856cb6cc48-94fw8                     1/1     Running            0                 7h35m

NAME                                TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE
service/hello-release-chart-hello   ClusterIP   10.109.103.8   <none>        80/TCP    7h1m
service/raw-app                     ClusterIP   10.106.70.8    <none>        80/TCP    7h35m

NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/hello-release-chart-hello   0/1     1            0           7h1m
deployment.apps/raw-app                     1/1     1            1           7h35m

NAME                                                   DESIRED   CURRENT   READY   AGE
replicaset.apps/hello-release-chart-hello-65b6bd8568   1         1         0       7h1m
replicaset.apps/raw-app-856cb6cc48                     1         1         1       7h35m