Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial commit for a tutorial on getting started with kustomize #4516

Merged

Conversation

rob8714
Copy link
Contributor

@rob8714 rob8714 commented Mar 12, 2022

An initial commit to tackle #3973

cc @KnVerey @natasha41575 @DavidJacob

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 12, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @rob8714. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 12, 2022
Copy link
Contributor

@DavidJacob DavidJacob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really clear and a good basic introduction, nice work! :)

I left a few comments, most of the minor things and some discussion on maybe how to consistently style some of this stuff going forward.

EOF
```

The `kustomization.yaml` files in the overlays are just including the `base` folder, so if you were to run `kustomize build` on the overlay folders at this point you would get the same output we got when we built `base`. The directory structure you created so far should look like this:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to point out that the the tutorial never explicitly gives the command for building the Staging and Production variants. While it might be obvious to a lot of people what command to run, it's probably best to include them both as some point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, I have added this in the build code blocks

We can achieve the names required by making use of `namePrefix` and `nameSuffix` as follows:


_Production overlay kustomization.yaml_:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A style I like in these tutorials is including the name of the file as a comment on top of the content. So in this case you'd have # overlays/production/kustomization.yaml instead of the "Production overlay kustomization.yaml" bit. Makes everything nice and explicit, the layout looks better and things are still simple to copy-paste without editing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the suggestion, have updated this as well. It would be nice if there could be a way to make this comment be an actual title for the code block, but haven't figured out if there's a way to do it or if it is possible yet

|Replicas |3 |2 |


We can achieve the names required by making use of `namePrefix` and `nameSuffix` as follows:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an actual name for things like namePrefix, nameSuffix, namespace, etc as we define in a kustomization.yaml file? Directives, commands, something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I avoided using a name to refer to these because I was unsure if they had one... @natasha41575 ?

Copy link
Contributor

@natasha41575 natasha41575 Mar 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an actual name for things like namePrefix, nameSuffix, namespace, etc as we define in a kustomization.yaml file? Directives, commands, something else?

I usually call them "fields in the kustomization file", "kustomization fields", etc. We can define a name for them if you'd like. I like the sound of directives, idk if there is a standard for these kinds of things already.

Maybe a Definitions section somewhere near the top of the doc? WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw in some of the docs that they are referred to as fields in some cases and I like the sound of directives for these more than fields, but thinking more about it maybe we have to be a bit careful about introducing new terms since they can also be referred to as transformers? Or define that directives and transformers may be used interchangeably?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My two cents: They can be "fields" when you're talking about the literal key you put into a Kustomization file, "transformers" when you're talking about the code that drives their functionality, or maybe "features" when you're being really abstract. "Directives" is already a (somewhat obscure) feature in this space: patch directives.

---

We're going to use kustomize to deploy an nginx instance into our Kubernetes cluster.
This page is intended to help you get started with using this amazing tool called kustomize! We will start off with creating a simple nginx deployment manifest and then use it as an example to explore kustomize basics.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a style guide on how we want to write the word kustomize consistently?

  • Kustomize?
  • kustomize?
  • kustomize?

I'm a fan of the last one but things can be a bit cluttered sometimes when you have too many words in backticks flying around.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the second one, the word kustomize will be used a lot and back ticking every single one will start to decrease its emphasis and/or may get annoying to look at.

@k8s-ci-robot
Copy link
Contributor

@rob8714: This PR has multiple commits, and the default merge method is: merge.
You can request commits to be squashed using the label: tide/merge-method-squash

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@rob8714
Copy link
Contributor Author

rob8714 commented Mar 13, 2022

Thanks for the review @DavidJacob! I did some changes based on your suggestions

@natasha41575
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 16, 2022
Copy link
Contributor

@natasha41575 natasha41575 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks great! I have some comments regarding the wording. I may do another pass at some point, but I think this is an excellent start. Thank you so much for doing this.

---

We're going to use kustomize to deploy an nginx instance into our Kubernetes cluster.
This page is intended to help you get started with using this amazing tool called kustomize! We will start off with creating a simple nginx deployment manifest and then use it as an example to explore kustomize basics.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the second one, the word kustomize will be used a lot and back ticking every single one will start to decrease its emphasis and/or may get annoying to look at.

|Replicas |3 |2 |


We can achieve the names required by making use of `namePrefix` and `nameSuffix` as follows:
Copy link
Contributor

@natasha41575 natasha41575 Mar 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an actual name for things like namePrefix, nameSuffix, namespace, etc as we define in a kustomization.yaml file? Directives, commands, something else?

I usually call them "fields in the kustomization file", "kustomization fields", etc. We can define a name for them if you'd like. I like the sound of directives, idk if there is a standard for these kinds of things already.

Maybe a Definitions section somewhere near the top of the doc? WDYT?

|Replicas |3 |2 |


We can achieve the names required by making use of `namePrefix` and `nameSuffix` as follows:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My two cents: They can be "fields" when you're talking about the literal key you put into a Kustomization file, "transformers" when you're talking about the code that drives their functionality, or maybe "features" when you're being really abstract. "Directives" is already a (somewhat obscure) feature in this space: patch directives.

```bash
mkdir -p kustomize-example-2/base kustomize-example-2/overlays/staging kustomize-example-2/overlays/production
cd kustomize-example-2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you feel strongly about restarting from scratch as of this step, vs. moving the existing files they've made into a new subdir? As it is this makes me wonder if it should be a second tutorial, since it is independent of what they've done so far.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, I started from scratch to avoid having to make them undo changes and keep the name short, can think of how to update later this week

Copy link
Contributor Author

@rob8714 rob8714 Mar 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KnVerey consolidated the example into one folder structure

nameSuffix: -staging

namespace: staging

replicas:
- name: nginx
- name: example-nginx
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@natasha41575 @KnVerey putting just nginx works here even though we are updating a resource coming from the base, is this expected?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, under the hood, the name reference transformer keeps track of all the names objects have had throughout the build, and as long as there's no ambiguity, it will successfully resolve the names either way.

@KnVerey KnVerey added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Mar 22, 2022
Copy link
Contributor

@KnVerey KnVerey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

nameSuffix: -staging

namespace: staging

replicas:
- name: nginx
- name: example-nginx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, under the hood, the name reference transformer keeps track of all the names objects have had throughout the build, and as long as there's no ambiguity, it will successfully resolve the names either way.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 22, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: KnVerey, rob8714

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 22, 2022
@k8s-ci-robot k8s-ci-robot merged commit 3490fb8 into kubernetes-sigs:master Mar 22, 2022
koba1t pushed a commit to koba1t/kustomize that referenced this pull request Apr 14, 2022
…rnetes-sigs#4516)

* Initial commit for a tutorial on getting started with kustomize

* add build commands and update comment with name of the file

* Update site/content/en/docs/Getting started/first_kustomization.md

Co-authored-by: David Jacob <[email protected]>

* Update site/content/en/docs/Getting started/first_kustomization.md

Co-authored-by: David Jacob <[email protected]>

* fix typo

* Update site/content/en/docs/Getting started/first_kustomization.md

Co-authored-by: Natasha Sarkar <[email protected]>

* Update site/content/en/docs/Getting started/first_kustomization.md

Co-authored-by: Natasha Sarkar <[email protected]>

* Update site/content/en/docs/Getting started/first_kustomization.md

Co-authored-by: Natasha Sarkar <[email protected]>

* Update site/content/en/docs/Getting started/first_kustomization.md

Co-authored-by: Natasha Sarkar <[email protected]>

* Update site/content/en/docs/Getting started/first_kustomization.md

Co-authored-by: Natasha Sarkar <[email protected]>

* Update site/content/en/docs/Getting started/first_kustomization.md

Co-authored-by: Natasha Sarkar <[email protected]>

* Update site/content/en/docs/Getting started/first_kustomization.md

Co-authored-by: Natasha Sarkar <[email protected]>

* Update site/content/en/docs/Getting started/first_kustomization.md

Co-authored-by: Natasha Sarkar <[email protected]>

* updates following review

* updates to getting started guide

* Update site/content/en/docs/Getting started/first_kustomization.md

Co-authored-by: Katrina Verey <[email protected]>

* Update site/content/en/docs/Getting started/first_kustomization.md

Co-authored-by: Katrina Verey <[email protected]>

* updates to consolidate example into one folder

Co-authored-by: David Jacob <[email protected]>
Co-authored-by: Natasha Sarkar <[email protected]>
Co-authored-by: Katrina Verey <[email protected]>
@veereshar
Copy link

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants