Delete k8s resources of a service deployed through "jx preview" and "jx promote" respectively in "preview" and "jx-staging" environments

1/28/2020

I am deploying the services using "jx preview" and "jx promote" commands respectively in "preview" and "jx-staging" in Jenkins-X.

I want to delete the resources (like deployments, services, pv's and pvc's etc) associated with that particular micro service deployed using jx commands.

Because when I deploy the same service in both "preview" and "jx-staging" environments the build fails because the service is already running on one port deployed in one of the namespaces.

So I want to delete the service resources (like deployments, services, pv's and pvc's etc) after it is deployed.

Please let me know the command to delete the resources associated with a micro service that is being deployed.

-- Bhavani Prasad
jenkins--x
kubernetes

1 Answer

1/28/2020

resources associated with Preview environments are garbage collected when the Pull Request associated with a Preview is closed. This works via a background CronJob which runs the jx gc previews command. You can eagerly run this yourself too.

If you really want to delete a preview by hand manually you can use jx delete preview.

The above works for previews. If you want to remove something from Staging or Production just modify the env/requirements.yaml file via a pull request or use jx delete application

-- James Strachan
Source: StackOverflow