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

QuickStart: Parameters #1601

Merged
merged 3 commits into from
May 27, 2021
Merged

Conversation

carolynvs
Copy link
Member

@carolynvs carolynvs commented May 21, 2021

What does this change

Second part of the quickstart that walks through how to set parameters with a flag or parameter set.

What issue does it fix

N/A

Notes for the reviewer

Ideally there was be sub menus under quickstart but I'd rather get the content out first then work with @flynnduism to get our nav bar to do what we want.

Checklist

  • Unit Tests
  • Documentation
  • Schema (porter.yaml)

@carolynvs
Copy link
Member Author

screenshot

Just trying out the new netlify preview functionality

Browser metadata
Path:      /quickstart/parameters/
Browser:   Firefox 88.0 on Mac OS 10.15
Viewport:  1440 x 692 @2x
Language:  en-US
Cookies:   Enabled

View on BrowserStack

Open Deploy Preview · Mark as Resolved

@carolynvs carolynvs force-pushed the params-quickstart branch from 15da68d to 361fa87 Compare May 21, 2021 23:17
@carolynvs carolynvs marked this pull request as ready for review May 21, 2021 23:30
@carolynvs carolynvs force-pushed the params-quickstart branch from 7d9de7c to 61a91d9 Compare May 21, 2021 23:30
@carolynvs carolynvs requested a review from iennae May 21, 2021 23:30
---

Now that you know how to install a bundle, let's look at how to specify parameters to customize how that bundle is installed.
Bundles can define parameters to allow the end-user to tweak how the bundle is configured.
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs to be active here.

Bundle authors add parameters to bundles so that end-users can tweak how the bundle is configured at installation. An example of where this would be useful is supplying a username and password value for a database.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am going to leave off the second sentence because a) those are most likely credentials and I don't want to confuse the issue of creds vs params just yet, and b) there are 3 examples of parameters in the next paragraph.

* Deployment Region: Let the user specify which region, such as eastus-1, where the application should be deployed.
* Helm Release Name: A bundle that uses Helm often will define a parameter that allows the user to set the release name for the Helm release.

For optional parameters, bundles set a default value that is used when the user does not specify a value for the parameter.
Copy link
Contributor

Choose a reason for hiding this comment

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

To make the parameter optional, you must set a default value for the parameter within the bundle.

Q: is the parameter optional here? Or really just optional at being specified. Just think this doesn't feel exactly precise.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just realized in the quickstart that the parameters are

namespace
wordpress-name
wordpress-password

and both namespace and wordpress-name are optional (required is set to false) and only wordpress-name has a default setting.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm a bit lost here and I think some of the confusion may being caused by the old/unused parameter field required. That isn't supported anymore to specifying if a parameter must be specified or not. If a default is set, then the parameter is optional and does not need to be specified by the user. If a default is not set, then the parameter is required. In a separate PR I will clean up any example porter.yaml files that are still using required: false or anything like that.

Does that help clear up this question? Or does the text still need to change?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahhhhhh! The output is confusing which is why I'm lost. so I think there is more nuance here and I'll need to chat to you more about it because optional feels like the wrong word

For optional parameters, bundles set a default value that is used when the user does not specify a value for the parameter.

Let's look at a bundle with parameters:

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if starting this out looking at the same bundle that was used in the quickstart (getporter/wordpress:v0.1..3) would be useful here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I decided to not use that bundle because it requires credentials, which we have not introduced yet, and a kubernetes cluster (more work for the reader that isn't relevant).

I used wordpress as an example earlier in the first quickstart because it is a bundle that has credentials, parameters, outputs and custom actions defined. That was useful because I was highlighting the output of porter explain, and if all the output said was "no credentials/parameters/outputs defined" then that wouldn't demonstrate the command very well. This is why later in the same quickstart I switched to the hello world bundle, so that we weren't using features that have not been explained yet.

No dependencies defined
```

The output tells us that the bundle has one optional string parameter, name, which defaults to "llama".
Copy link
Contributor

Choose a reason for hiding this comment

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

I keep reading this example as llama as in llamar "to call" you call me ..

Copy link
Contributor

Choose a reason for hiding this comment

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

In the Parameters section of the output returned by explain, there is a single optional string parameter, name, with a default of "llama" that applies to "All Actions".

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup! that is the hidden joke. 😀

```

The output tells us that the bundle has one optional string parameter, name, which defaults to "llama".
The name parameter applies to "All Actions" meaning that this parameter can be specified with every action that the bundle defines.
Copy link
Contributor

Choose a reason for hiding this comment

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

This means that the name parameter can be specified with each action that the bundle defines.


The output tells us that the bundle has one optional string parameter, name, which defaults to "llama".
The name parameter applies to "All Actions" meaning that this parameter can be specified with every action that the bundle defines.
Since it says that no custom actions are defined, the bundle only supports the built-in actions of install, upgrade, and uninstall.
Copy link
Contributor

Choose a reason for hiding this comment

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

In the custom actions section of the output returned by explain, there are no custom actions defined. The hello-llama bundle only supports the built-in actions of install, upgrade, and uninstall.

## Use the default parameter values


First install the bundle and do not specify any parameters so that you can observe how the bundle installs without any customization.
Copy link
Contributor

Choose a reason for hiding this comment

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

Install the bundle without specifying any parameters so that you can see the default behavior of the bundle install.

The bundle printed "Hello, llama" using the default value for the name parameter.

## Specify a parameter with a flag
Next upgrade the installation and change the name parameter to another value.
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's see the behavior when customizing the bundle with parameters. Upgrade the bundle and specify the name parameter.


## Specify a parameter with a flag
Next upgrade the installation and change the name parameter to another value.
Parameters are specified with the \--param flag:
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels like it should be explained earlier before we start experimenting.

Parameters are specified with the \--param flag:

```console
$ porter upgrade hello-llama --param name=Porter
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe use a different name than Porter so it isn't confusing to new folks. (Michele?)

```

## Create a Parameter Set
Setting a parameter value individually on the command line with the \--param flag works well when trying out a bundle.
Copy link
Contributor

Choose a reason for hiding this comment

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

While trying out a bundle, it might work well when you set individual parameter values on the command line with the --param flag.

## Create a Parameter Set
Setting a parameter value individually on the command line with the \--param flag works well when trying out a bundle.
When working with a bundle often though, remembering and typing out every parameter values every time is error prone.
Parameter Sets store a set of parameter values to use with a bundle.
Copy link
Contributor

Choose a reason for hiding this comment

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

To alleviate errors and the requirement of remembering and manually configuring parameters at the command line, you can store a set of parameter values to use with a bundle with a parameter set.

Setting a parameter value individually on the command line with the \--param flag works well when trying out a bundle.
When working with a bundle often though, remembering and typing out every parameter values every time is error prone.
Parameter Sets store a set of parameter values to use with a bundle.
Even more powerful, the value of the parameters can come from the following sources:
Copy link
Contributor

Choose a reason for hiding this comment

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

more powerful than what?

* secret

Some parameters may be sensitive, for example a database connection string or oauth token.
For improved security, and to limit exposure of sensitive values, it is recommended that you source those parameter values from a secret store such as Hashicorp Vault or Azure Key Vault.
Copy link
Contributor

Choose a reason for hiding this comment

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

For improved security, and to limit exposure of sensitive values, it is recommended that you source sensitive parameter values from a secret store such as HashiCorp Vault, Azure Key Vault or Google Secret Manager.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can't mention google because no one has made a plugin for that yet.

Copy link
Contributor

Choose a reason for hiding this comment

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

AHHH. just cut the Google Secret Manager out and keep the "sensitive parameter values" (instead of those)

? Enter the value that will be used to set parameter "name"
Porter
```

Copy link
Contributor

Choose a reason for hiding this comment

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

What if I want to accept a default value for a particular parameter?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can there only be one parameter set per bundle? What happens if I re-run generate?

Copy link
Member Author

@carolynvs carolynvs May 24, 2021

Choose a reason for hiding this comment

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

What if I want to accept a default value for a particular parameter?

Let me make an issue for that (#1604). Right now the answer is manually edit the parameter set to remove the parameter mapping from the file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can there only be one parameter set per bundle? What happens if I re-run generate?

I have answers but I'm not sure if that level of detail belongs in the quickstart, which is a task focused document and isn't intended to be a complete reference of the topic. A better place to answer those questions is porter.sh/parameters I think. We already say in the command-line documentation for the --parameter-set flag that it can be used more than once.

  1. Yes you can define multiple parameter sets and use them when installing a bundle.
  2. Re-running generate, runs you through the same process as the first time. If you choose the same parameter set name the previous parameter set is overwritten.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, wasn't saying that these things need to defined here but wondering if folks have more questions if they were answered somewhere.

@carolynvs
Copy link
Member Author

@iennae Thanks for the thoughtful suggestions! I've updated it with your feedback.

carolynvs added 3 commits May 24, 2021 13:37
Second part of the quickstart that walks through how to set parameters
with a flag or parameter set.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
@carolynvs carolynvs force-pushed the params-quickstart branch from 9a69550 to 88a493c Compare May 24, 2021 18:38
Copy link
Contributor

@iennae iennae left a comment

Choose a reason for hiding this comment

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

LGTM

@carolynvs carolynvs merged commit 7f8906b into getporter:main May 27, 2021
@carolynvs carolynvs deleted the params-quickstart branch May 27, 2021 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants