Removing an application will free quota resources and enable you to deploy other applications. OAM applications are defined by an application configuration entity that links all the components that form the application applying traits and scopes. To remove an application, you will need to delete all associated entities.
- Playground tools are installed
- kubectl if you prefer to remove the application with it
$ playground login Login success
The simplest way to remove an application is using the playground command, execute:
$ playground apps delete <appName>
this command deletes the application and its components and scopes at once.
Anyway, there are two more methods to remove an application depending on how it was deployed and the access to the original sources.
In these cases you need to obtain kubeconfig file to connect to your cluster.
$ playground get-kubeconfig ASSOCIATED SERVER https://18.104.22.168 Use this kubeconfig to connect to the cluster and deploy applications: kubectl --kubeconfig <napptive-kubeconfig> ...
If you created the application from a directory, you can use the following shortcut:
$ kubectl --kubeconfig <path_to>/napptive-kubeconfig delete -f /<path_to>/myapp
To remove an application, identify which are the elements that compose it. The easiest method is to get the information from the application configuration.
$ kubectl --kubeconfig <path_to>/napptive-kubeconfig describe applicationconfigurations.core.oam.dev my-wordpress ... Spec: Components: Component Name: mysql-db Parameter Values: Name: password Value: root Name: portNumber Value: 3306 Scopes: Scope Ref: API Version: core.oam.dev/v1alpha2 Kind: HealthScope Name: wordpress-health Component Name: wordpress Parameter Values: Name: dbpass Value: root Name: host Value: mysql-db Scopes: Scope Ref: API Version: core.oam.dev/v1alpha2 Kind: HealthScope Name: wordpress-health Traits: Trait: API Version: core.oam.dev/v1alpha2 Kind: ManualScalerTrait Metadata: Name: wordpress-replication Spec: Replica Count: 1
From the output we can identify that the application is composed by:
wordpresswhich are the two components of the application.
wordpress-healthwhich is a HealthScope.
wordpress-replicationwhich is a ManualScalerTrait.
To remove the app execute:
$ kubectl --kubeconfig <path_to>/napptive-kubeconfig delete applicationconfigurations.core.oam.dev my-wordpress applicationconfiguration.core.oam.dev "my-wordpress" deleted $ kubectl --kubeconfig <path_to>/napptive-kubeconfig delete components.core.oam.dev mysql-db wordpress component.core.oam.dev "mysql-db" deleted component.core.oam.dev "wordpress" deleted $ kubectl --kubeconfig <path_to>/napptive-kubeconfig delete healthscopes.core.oam.dev wordpress-health healthscope.core.oam.dev "wordpress-health" deleted
Note that the lifecycle of the ManualScalerTrait is linked with the application configuration, so it will be automatically removed.
In case you want to remove all applications in your cluster, use the following commands:
$ kubectl --kubeconfig <path_to>/napptive-kubeconfig delete --all applicationconfigurations.core.oam.dev $ kubectl --kubeconfig <path_to>/napptive-kubeconfig delete --all components.core.oam.dev $ kubectl --kubeconfig <path_to>/napptive-kubeconfig delete --all manualscalertraits.core.oam.dev $ kubectl --kubeconfig <path_to>/napptive-kubeconfig delete --all healthscopes.core.oam.dev
Notice that the order in which elements are removed is important as entities are linked together. Please follow the recommended order of removal. If you get an entity stuck in a finalizer, recreate the dependent entity and proceed with the removal process.
- Check our tutorials on how to deploy predefined applications