|
| 1 | +--- |
| 2 | +title: Deploy Kubernetes Inline Manifests |
| 3 | +sidebar_label: InlineManifests |
| 4 | +--- |
| 5 | + |
| 6 | +import FragmentKubectlApplyArgs from '../../../_partials/kubectl-options-applyArgs.mdx'; |
| 7 | +import FragmentKubectlBinaryPath from '../../../_partials/kubectl-options-binaryPath.mdx'; |
| 8 | +import FragmentKubectlKustomize from '../../../_partials/kubectl-kustomize.mdx'; |
| 9 | +import FragmentKustomizeKustomizeArgs from '../../../_partials/kustomize-options-kustomizeArgs.mdx'; |
| 10 | +import FragmentUpdateImageTags from '../../../_partials/kubectl-updateImageTags.mdx'; |
| 11 | + |
| 12 | +To deploy Kubernetes using inline manifests with `kubectl apply`, you need to configure them within the `deployments` section of the `devspace.yaml`. |
| 13 | + |
| 14 | + |
| 15 | +## Example |
| 16 | +```yaml title=devspace.yaml |
| 17 | +pipelines: |
| 18 | + dev: |
| 19 | + run: | |
| 20 | + create_deployments backend |
| 21 | + create_deployments frontend |
| 22 | +deployments: |
| 23 | + backend: |
| 24 | + kubectl: |
| 25 | + inlineManifest: |
| 26 | + apiVersion: v1 |
| 27 | + kind: Pod |
| 28 | + metadata: |
| 29 | + name: busybox-sleep |
| 30 | + spec: |
| 31 | + containers: |
| 32 | + - name: busybox |
| 33 | + image: busybox:1.28 |
| 34 | + args: |
| 35 | + - sleep |
| 36 | + - "1000000" |
| 37 | + frontend: |
| 38 | + kubectl: |
| 39 | + manifests: |
| 40 | + - frontend/manifest.yaml |
| 41 | +``` |
| 42 | +
|
| 43 | +The above example will be executed during the deployment process as follows: |
| 44 | +```bash |
| 45 | +cat <<EOF | kubectl apply -f - |
| 46 | +apiVersion: v1 |
| 47 | +kind: Pod |
| 48 | +metadata: |
| 49 | + name: busybox-sleep |
| 50 | +spec: |
| 51 | + containers: |
| 52 | + - name: busybox |
| 53 | + image: busybox:1.28 |
| 54 | + args: |
| 55 | + - sleep |
| 56 | + - "1000000" |
| 57 | +EOF |
| 58 | +``` |
| 59 | + |
| 60 | + |
| 61 | +## Update Image Tags |
| 62 | + |
| 63 | +<FragmentUpdateImageTags/> |
| 64 | + |
| 65 | + |
| 66 | +## `kubectl` Binary |
| 67 | +Deployments with `kubectl` require `kubectl` to be installed. If the `kubectl` binary cannot be found within the `$PATH` variable and it is not specified by specifying the [`kubectlBinaryPath` option](./README.mdx#deployments-kubectl-kubectlBinaryPath), DevSpace will download the `kubectl` binary into the `$HOME/.devspace/bin` folder. |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | +## Extra Arguments |
| 72 | +When deploying manifests via `kubectl`, DevSpace can pass additional arguments and flags to the `kubectl` commands used for the deployment process. |
| 73 | + |
| 74 | +### Args For `kubectl create` |
| 75 | +The `createArgs` option expects an array of strings stating additional arguments (and flags) that should be used when calling `kubectl create`. |
| 76 | + |
| 77 | +#### Example: Custom Kubectl Args & Flags |
| 78 | +```yaml |
| 79 | +deployments: |
| 80 | + backend: |
| 81 | + kubectl: |
| 82 | + inlineManifest: |
| 83 | + apiVersion: v1 |
| 84 | + kind: Pod |
| 85 | + metadata: |
| 86 | + name: busybox-sleep |
| 87 | + spec: |
| 88 | + containers: |
| 89 | + - name: busybox |
| 90 | + image: busybox:1.28 |
| 91 | + args: |
| 92 | + - sleep |
| 93 | + - "1000000" |
| 94 | + createArgs: |
| 95 | + - "--recursive" |
| 96 | +``` |
| 97 | +**Explanation:** |
| 98 | +Deploying the above example would roughly be equivalent to this command: |
| 99 | +```bash |
| 100 | +cat <<EOF | kubectl create --dry-run --output yaml --validate=false --recursive -f - |
| 101 | +apiVersion: v1 |
| 102 | +kind: Pod |
| 103 | +metadata: |
| 104 | + name: busybox-sleep |
| 105 | +spec: |
| 106 | + containers: |
| 107 | + - name: busybox |
| 108 | + image: busybox:1.28 |
| 109 | + args: |
| 110 | + - sleep |
| 111 | + - "1000000" |
| 112 | +EOF |
| 113 | +``` |
| 114 | + |
| 115 | + |
| 116 | +### Args For `kubectl apply` |
| 117 | + |
| 118 | +<FragmentKubectlApplyArgs/> |
0 commit comments