github.com/wmuizelaar/kpt@v0.0.0-20221018115725-bd564717b2ed/site/book/06-deploying-packages/02-applying-a-package.md (about) 1 Once you have initialized the package, you can deploy it using `live apply`. 2 3 The `wordpress` package requires a `Secret` containing the mysql password. 4 Let's create that first: 5 6 ```shell 7 $ kubectl create secret generic mysql-pass --from-literal=password=YOUR_PASSWORD 8 ``` 9 10 !> You can also declare the `Secret` resource, but make sure it is not committed to 11 Git as part of the package. 12 13 Then deploy the package and wait for the resources to be reconciled: 14 15 ```shell 16 $ kpt live apply wordpress --reconcile-timeout=2m 17 installing inventory ResourceGroup CRD. 18 service/wordpress created 19 service/wordpress-mysql created 20 deployment.apps/wordpress created 21 deployment.apps/wordpress-mysql created 22 persistentvolumeclaim/mysql-pv-claim created 23 persistentvolumeclaim/wp-pv-claim created 24 6 resource(s) applied. 6 created, 0 unchanged, 0 configured, 0 failed 25 service/wordpress reconcile pending 26 service/wordpress-mysql reconcile pending 27 deployment.apps/wordpress reconcile pending 28 deployment.apps/wordpress-mysql reconcile pending 29 persistentvolumeclaim/mysql-pv-claim reconcile pending 30 persistentvolumeclaim/wp-pv-claim reconcile pending 31 service/wordpress reconciled 32 service/wordpress-mysql reconciled 33 persistentvolumeclaim/mysql-pv-claim reconciled 34 persistentvolumeclaim/wp-pv-claim reconciled 35 deployment.apps/wordpress-mysql reconciled 36 deployment.apps/wordpress reconciled 37 6 resource(s) reconciled, 0 skipped, 0 failed to reconcile, 0 timed out 38 ``` 39 40 ?> Refer to the [apply command reference][apply-doc] for usage. 41 42 ## `ResourceGroup` CRD 43 44 By default, `live apply` automatically installs the `ResourceGroup` CRD (unless 45 `--dry-run` is specified) since it needs to create the associated 46 `ResourceGroup` custom resource. You can also manually install the CRD before 47 running `live apply`: 48 49 ```shell 50 $ kpt live install-resource-group 51 ``` 52 53 ?> Installing this CRD requires sufficient ClusterRole permission, so you may 54 need to ask your cluster admin to install it for you. 55 56 ## Server-side vs Client-side apply 57 58 By default, `live apply` command uses client-side apply. The updates are 59 accomplished by calculating and sending a patch from the client. Server-side 60 apply, which can be enabled with the `--server-side` flag, sends the entire 61 resource to the server for the update. 62 63 ## Dry-run 64 65 You can use the `--dry-run` flag to get break down of operations that will be 66 performed when applying the package. 67 68 For example, before applying the `wordpresss` package for the first time, you 69 would see that 6 resources would be created: 70 71 ```shell 72 $ kpt live apply wordpress --dry-run 73 Dry-run strategy: client 74 service/wordpress created 75 service/wordpress-mysql created 76 deployment.apps/wordpress created 77 deployment.apps/wordpress-mysql created 78 persistentvolumeclaim/mysql-pv-claim created 79 persistentvolumeclaim/wp-pv-claim created 80 6 resource(s) applied. 6 created, 0 unchanged, 0 configured, 0 failed 81 0 resource(s) pruned, 0 skipped, 0 failed 82 ``` 83 84 When combined with server-side apply, the resources in the package pass through 85 all the validation steps on the API server. 86 87 ## Observe the package 88 89 After you have deployed the package, you can get its current status at any time: 90 91 ```shell 92 $ kpt live status wordpress 93 service/wordpress is Current: Service is ready 94 service/wordpress-mysql is Current: Service is ready 95 deployment.apps/wordpress is Current: Deployment is available. Replicas: 1 96 deployment.apps/wordpress-mysql is Current: Deployment is available. Replicas: 1 97 persistentvolumeclaim/mysql-pv-claim is Current: PVC is Bound 98 persistentvolumeclaim/wp-pv-claim is Current: PVC is Bound 99 ``` 100 101 ?> Refer to the [status command reference][status-doc] for usage. 102 103 ## Delete the package 104 105 To delete all the resources in a package, you can use the `live destroy` 106 command: 107 108 ```shell 109 $ kpt live destroy wordpress 110 persistentvolumeclaim/wp-pv-claim deleted 111 persistentvolumeclaim/mysql-pv-claim deleted 112 deployment.apps/wordpress-mysql deleted 113 deployment.apps/wordpress deleted 114 service/wordpress-mysql deleted 115 service/wordpress deleted 116 6 resource(s) deleted, 0 skipped, 0 failed to delete 117 persistentvolumeclaim/wp-pv-claim reconcile pending 118 persistentvolumeclaim/mysql-pv-claim reconcile pending 119 deployment.apps/wordpress-mysql reconcile pending 120 deployment.apps/wordpress reconcile pending 121 service/wordpress-mysql reconcile pending 122 service/wordpress reconcile pending 123 deployment.apps/wordpress-mysql reconciled 124 deployment.apps/wordpress reconciled 125 service/wordpress-mysql reconciled 126 service/wordpress reconciled 127 persistentvolumeclaim/mysql-pv-claim reconciled 128 persistentvolumeclaim/wp-pv-claim reconciled 129 6 resource(s) reconciled, 0 skipped, 0 failed to reconcile, 0 timed out 130 ``` 131 132 ?> Refer to the [destroy command reference][destroy-doc] for usage. 133 134 [apply-doc]: /reference/cli/live/apply/ 135 [status-doc]: /reference/cli/live/status/ 136 [destroy-doc]: /reference/cli/live/destroy/