We have recently moved from a pure kubernetes deployment to a helm chart deployment for one of our apps.
I'm trying to find a way to migrate a cluster that is currently running the old deployment to use the new helm chart.
I'm having an issue because the helm chart won't cleanly install when there are existing resources on the cluster that are the same as what it is installing. For example I have a service that looks like this
$ kubectl get service elasticsearch -oyaml
apiVersion: v1
kind: Service
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"creationTimestamp":"2018-01-26T01:39:20Z","labels":{"app":"elasticsearch"},"name":"elasticsearch","namespace":"default","resourceVersion":"18650241","selfLink":"/api/v1/namespaces/default/services/elasticsearch","uid":"bac30dfa-0239-11e8-b7a8-0015b2aa5ea6"},"spec":{"externalName":"100.64.0.100","sessionAffinity":"None","type":"ExternalName"},"status":{"loadBalancer":{}}}
creationTimestamp: 2018-10-04T21:22:06Z
labels:
app: elasticsearch
name: elasticsearch
namespace: default
resourceVersion: "31430"
selfLink: /api/v1/namespaces/default/services/elasticsearch
uid: 8b82157e-c81b-11e8-a0d8-94c69116956d
spec:
externalName: 127.0.0.1
sessionAffinity: None
type: ExternalName
status:
loadBalancer: {}
and my helm chart has a template that looks like this
$ cat elasticsearch.yaml
apiVersion: v1
kind: Service
metadata:
labels:
app: elasticsearch
name: elasticsearch
spec:
type: ExternalName
externalName: 127.0.0.1
status:
load_balancer: {}
If I try to apply my chart using
$ helm install /path/to/chart --name=chart-name
It will fail with this error
Error: release chart-name failed: services "elasticsearch" already exists
To make matters worse even thought thee install fails the chart will appear in helm with the status FAILED. If I then delete the chart it will remove some of the running deployments.
I have two questions.
1) How can I install my chart and have it take control over the exisitng service.
2) Is it possible to remove a failed chart from helm without deleting the running deployments?