Skip to content

Commit 4738873

Browse files
sarahmaddoxk8s-ci-robot
authored andcommitted
Expands info on config with kustomize (#1093)
* Moved the kustomize doc to the config section. * Expanded the kustomize guide and fixed links. * More content tweaks. * Still more content tweaks. * Added punctuation and indents as requested in review comments. * Added a section on using the init command. * WIP need more detail on how to edit KfDef. * Added a better customisation example.
1 parent 466c106 commit 4738873

File tree

5 files changed

+269
-97
lines changed

5 files changed

+269
-97
lines changed

content/_redirects

+4-2
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,13 @@ docs/started/requirements/ /docs/started/getting-started/
8787
/docs/started/getting-started-gke/ /docs/started/cloud/getting-started-gke/
8888
/docs/started/getting-started-icp/ /docs/started/cloud/getting-started-icp/
8989

90-
9190
/docs/other-guides/job-scheduling/ /docs/use-cases/job-scheduling/
9291
/docs/other-guides/upgrade/ /docs/upgrading/upgrade/
9392

9493
/docs/use-cases/kubeflow-on-multinode-cluster/ /docs/other-guides/kubeflow-on-multinode-cluster/
9594

9695
# Remove Kubeflow installation on existing EKS cluster
97-
/docs/aws/deploy/existing-cluster/ /docs/aws/deploy/install-kubeflow/
96+
/docs/aws/deploy/existing-cluster/ /docs/aws/deploy/install-kubeflow/
97+
98+
# Move the kustomize guide to the config section
99+
/docs/components/misc/kustomize/ /docs/other-guides/kustomize/

content/docs/components/misc/kustomize.md

-88
This file was deleted.

content/docs/gke/deploy/deploy-cli.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ Your Kubeflow app directory **${KFAPP}** contains the following files and direct
189189
190190
* **kustomize** is a directory that contains the kustomize packages for Kubeflow
191191
applications. See
192-
[how Kubeflow uses kustomize](/docs/components/misc/kustomize/).
192+
[how Kubeflow uses kustomize](/docs/other-guides/kustomize/).
193193
194194
* The directory is created when you run `kfctl generate`.
195195
* You can customize the Kubernetes resources by modifying the manifests and
+259
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
+++
2+
title = "Configuring Kubeflow with kfctl and kustomize"
3+
description = "The basics of Kubeflow configuration with kfctl and kustomize"
4+
weight = 10
5+
+++
6+
7+
Kfctl is the Kubeflow command-line interface (CLI) that you can use to
8+
install and configure Kubeflow.
9+
10+
Kubeflow makes use of [kustomize](https://kustomize.io/) to help customize YAML
11+
configurations. With kustomize, you can traverse a Kubernetes manifest to add,
12+
remove, or update configuration options without forking the manifest. A
13+
_manifest_ is a YAML file containing a description of the applications that you
14+
want to include in your Kubeflow deployment.
15+
16+
## Overview of kfctl and kustomize
17+
18+
This section describes how kfctl works with kustomize to set up your
19+
Kubeflow deployment.
20+
21+
### The Kubeflow installation process
22+
23+
Kfctl is the Kubeflow CLI that you can use to set up a Kubernetes cluster with
24+
Kubeflow installed, or to deploy Kubeflow to an existing Kubernetes cluster.
25+
See the [Kubeflow getting-started guide](/docs/started/getting-started/) for
26+
installation instructions based on your deployment scenario.
27+
28+
The deployment process consists of three steps, _init_, _generate_, and
29+
_apply_, so that you can modify your configuration before actually deploying
30+
Kubeflow.
31+
32+
* `kfctl init` - one time set up.
33+
* `kfctl generate` - creates config files defining the various resources.
34+
* `kfctl apply` - creates or updates the resources.
35+
36+
### Specifying a configuration file when initializing your deployment
37+
38+
When you install Kubeflow, the deployment process uses one of a few possible
39+
YAML configuration files to bootstrap the configuration.
40+
41+
Typically, you specify the configuration file with a `--config` parameter
42+
when you run `kfctl init`. For example:
43+
44+
```
45+
export KFAPP="<your choice of application directory name>"
46+
export CONFIG="https://raw.githubusercontent.com/kubeflow/kubeflow/{{% kf-latest-version %}}/bootstrap/config/kfctl_existing_arrikto.yaml"
47+
kfctl init ${KFAPP} --config=${CONFIG} -V
48+
```
49+
50+
*For details of the above deployment, see the guide to deployment using the
51+
[kfctl_existing_arrikto configuration](/docs/started/k8s/kfctl-existing-arrikto/).*
52+
53+
Some deployment processes use a default config file and you don't need to
54+
add the `--config` argument. For example, the
55+
Google Cloud Platform (GCP) initialization command looks like this:
56+
57+
```
58+
export PROJECT="<your GCP project ID>"
59+
export KFAPP="<your choice of application directory name>"
60+
kfctl init ${KFAPP} --platform gcp --project ${PROJECT}
61+
```
62+
63+
*For details of the above deployment, see the guide to deployment
64+
[on GCP using the CLI](/docs/gke/deploy/deploy-cli/).*
65+
66+
### Your Kubeflow directory layout
67+
68+
Your Kubeflow app directory is the directory where you choose to store
69+
your Kubeflow configurations during deployment. This guide refers to the
70+
directory as `${KFAPP}`. The directory contains the following files and
71+
directories:
72+
73+
* **app.yaml** stores your primary Kubeflow configuration in the form of a
74+
`KfDef` Kubernetes object.
75+
76+
* The values are set when you run `kfctl init`.
77+
* The values are snapshotted inside `app.yaml` to make your app
78+
self contained.
79+
* The YAML defines each Kubeflow application as a kustomize package.
80+
81+
* **[platform-name]_config** is a directory that contains
82+
configurations specific to your chosen platform or cloud provider. This
83+
directory may or may not be present, depending on your setup.
84+
85+
* The directory is created when you run `kfctl generate platform`.
86+
* To customize these configurations, you can modify parameters in the `KfDef`
87+
object in your `app.yaml` file, and then re-run `kfctl generate` and
88+
`kfctl apply`.
89+
90+
* **kustomize** is a directory that contains Kubeflow application manifests.
91+
That is, the directory contains the kustomize packages for the Kubeflow
92+
applications that are included in your deployment.
93+
94+
* The directory is created when you run `kfctl generate`.
95+
* To customize these configurations, you can modify parameters in the `KfDef`
96+
object in your `app.yaml` file, and then re-run `kfctl generate` and
97+
`kfctl apply`.
98+
99+
### How your configuration is generated
100+
101+
The content of your `app.yaml` is the result of running kustomize
102+
on the base and overlay `kustomization.yaml` files in the
103+
[Kubeflow config](https://github.com/kubeflow/kubeflow/tree/master/bootstrap/config)
104+
directory. The overlays reflect the options that you choose when calling
105+
`kfctl init`.
106+
107+
Below are some examples of `KfDef` configuration files:
108+
109+
* [kfctl_k8s_istio.yaml](https://github.com/kubeflow/kubeflow/blob/master/bootstrap/config/kfctl_k8s_istio.yaml)
110+
to install Kubeflow on an existing Kubernetes cluster.
111+
* [kfctl_gcp_basic_auth.yaml](https://github.com/kubeflow/kubeflow/blob/master/bootstrap/config/kfctl_gcp_basic_auth.yaml)
112+
to set up a Google Kubernetes Engine (GKE) cluster with Kubeflow using basic
113+
authentication.
114+
115+
The kustomize package manager in kfctl uses the information in your
116+
`app.yaml` to traverse the directories under the
117+
[Kubeflow manifests](https://github.com/kubeflow/manifests) and to
118+
create kustomize build targets based on the manifests.
119+
120+
## Installing kustomize
121+
122+
Make sure that you have the minimum required version of kustomize:
123+
<b>{{% kustomize-min-version %}}</b> or later.
124+
125+
1. Follow the [kustomize installation
126+
guide](https://github.com/kubernetes-sigs/kustomize/blob/master/docs/INSTALL.md),
127+
choosing the relevant options for your operating system. For example, if
128+
you're on Linux:
129+
130+
* Set some variables for the operating system:
131+
132+
```
133+
export opsys=linux
134+
```
135+
136+
* Download the kustomize binary:
137+
138+
```
139+
curl -s https://api.github.com/repos/kubernetes-sigs/kustomize/releases/latest |\
140+
grep browser_download |\
141+
grep $opsys |\
142+
cut -d '"' -f 4 |\
143+
xargs curl -O -L
144+
```
145+
146+
* Move the binary:
147+
148+
```
149+
mkdir -p ${HOME}/bin
150+
mv kustomize_*_${opsys}_amd64 ${HOME}/bin/kustomize
151+
chmod u+x ${HOME}/bin/kustomize
152+
```
153+
154+
1. Include the `kustomize` command in your path:
155+
156+
```
157+
export PATH=$PATH:${HOME}/bin/kustomize
158+
```
159+
160+
## Modifying configuration before deployment
161+
162+
Kustomize lets you customize raw, template-free YAML files for multiple
163+
purposes, leaving the original YAML untouched and usable as is.
164+
165+
You can use the following command to build and apply kustomize directories:
166+
167+
```
168+
kustomize build <kustomization_directory> | kubectl apply -f -
169+
```
170+
171+
The [Kubeflow manifests repo](https://github.com/kubeflow/manifests) contains
172+
kustomize build targets, each with a `base` directory. You can use kustomize to
173+
generate YAML output and pass it to kfctl. You can also make
174+
changes to the kustomize targets in the manifests repo as needed.
175+
176+
## Modifying the configuration of an existing deployment
177+
178+
To customize the Kubeflow resources running within the cluster, you can modify
179+
parameters in the `KfDef` object in your `${KFAPP}/app.yaml` file, where
180+
`KFAPP` is the directory where you stored your Kubeflow configurations during
181+
deployment. Then re-run `kfctl generate` and `kfctl apply`.
182+
183+
For example, to modify settings for the Spartakus usage reporting tool within
184+
your Kubeflow deployment:
185+
186+
1. Edit the configuration file at `${KFAPP}/app.yaml`.
187+
188+
1. Find and replace the parameter values for `spartakus` to suit your
189+
requirements:
190+
191+
- kustomizeConfig:
192+
parameters:
193+
- initRequired: true
194+
name: usageId
195+
value: <randomly-generated-id>
196+
- initRequired: true
197+
name: reportUsage
198+
value: "true"
199+
repoRef:
200+
name: manifests
201+
path: common/spartakus
202+
name: spartakus
203+
204+
1. Due to
205+
[Kubeflow issue #3810](https://github.com/kubeflow/kubeflow/issues/3810),
206+
you currently need to tear down your Kubeflow cluster before applying the
207+
configuration change. This command **deletes all your Kubeflow resources**:
208+
209+
```
210+
cd ${KFAPP}
211+
kfctl delete all -V
212+
```
213+
214+
215+
1. Regenerate and deploy your Kubeflow resources:
216+
217+
```
218+
cd ${KFAPP}
219+
kfctl generate all -V
220+
kfctl apply all -V
221+
```
222+
223+
224+
### More examples
225+
226+
For examples of customizing your deployment, see the guide to [customizing
227+
Kubeflow on GKE](/docs/gke/customizing-gke/).
228+
229+
For information about how Kubeflow uses Spartakus, see the guide to
230+
[usage reporting](/docs/other-guides/usage-reporting/).
231+
232+
## More about kustomize
233+
234+
Below are some useful kustomize terms, from the
235+
[kustomize glossary](https://github.com/kubernetes-sigs/kustomize/blob/master/docs/glossary.md):
236+
237+
* **base:** A combination of a kustomization and resource(s). Bases can be
238+
referred to by other kustomizations.
239+
240+
* **kustomization:** Refers to a `kustomization.yaml` file, or more generally to
241+
a directory containing the `kustomization.yaml` file and all the relative file
242+
paths that the YAML file references.
243+
244+
* **overlay:** A combination of a kustomization that refers to a base, and a
245+
patch. An overlay may have multiple bases.
246+
247+
* **patch:** General instructions to modify a resource.
248+
249+
* **resource:** Any valid YAML file that defines an object with a kind and a
250+
metadata/name field.
251+
252+
* **target:** The argument to `kustomize build`. For example,
253+
`kustomize build $TARGET`. A target must be a path or a URL to a
254+
kustomization. A target can be a base or an overlay.
255+
256+
* **variant:** The outcome of applying an overlay to a base.
257+
258+
Read more about kustomize in the
259+
[kustomize documentation](https://github.com/kubernetes-sigs/kustomize/tree/master/docs).

0 commit comments

Comments
 (0)