Skip to content

Commit f9fc86d

Browse files
committed
add helm cli tutorial
1 parent 7b46f44 commit f9fc86d

File tree

6 files changed

+396
-0
lines changed

6 files changed

+396
-0
lines changed

docs/vendor/tutorial-helm-cli.mdx

Lines changed: 396 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,396 @@
1+
import DependencyYaml from "../partials/replicated-sdk/_dependency-yaml.mdx"
2+
import HelmPackage from "../partials/helm/_helm-package.mdx"
3+
import Requirements from "../partials/embedded-cluster/_requirements.mdx"
4+
5+
# Install SlackerNews with the Helm CLI
6+
7+
This topic provides a tutorial that demonstrates how to install a sample application using the Helm CLI.
8+
9+
## Introduction
10+
11+
This tutorial shows how to install a Helm chart distributed with Replicated using the Helm CLI.
12+
13+
In this tutorial, you will:
14+
15+
* Download the Helm chart for the sample application (SlackerNews)
16+
17+
* Create a release for SlackerNews in the Replicated Platform
18+
19+
* Get the Helm CLI installation instructions for SlackerNews from the Replicated Enterprise Portal
20+
21+
* Install SlackerNews using the Helm CLI in a Kubernetes cluster
22+
23+
## Set Up Your Environment
24+
25+
Before you begin, do the following to set up your environment:
26+
27+
* Install the Helm CLI, which is the tool for interacting with Helm and managing Helm charts. See [Install Helm](/vendor/environment-setup#install-helm).
28+
29+
* Ensure that you have access to a cluster that meets the requirements for Embedded Cluster:
30+
31+
* **Option 1: Use Compatibility Matrix.** To use Replicated Compatibility Matrix to create a cluster for this tutorial, first request Compatibility Matrix credits. You can request credits by creating a Vendor Portal account and then going to [**Compatibility Matrix > Request more credits**](https://vendor.replicated.com/compatibility-matrix) in the Vendor Portal. For more information about creating an account, see [Create a Vendor Account](vendor-portal-creating-account). For more information about Compatibility Matrix credits, see [Billing and Credits](/vendor/testing-about#billing-and-credits).
32+
33+
:::note
34+
If you are new to the Replicated platform, you might be eligible for $100 in free Compatibility Matrix credits. To request your free credits, reach out to our sales team at https://www.replicated.com/contact and note in the comments that you are completing a Replicated tutorial.
35+
:::
36+
37+
After you complete the prerequisites above, continue to the [Tutorial](#tutorial). You will create the cluster with Compatibility Matrix as part of the tutorial.
38+
39+
* **Option 2: Bring your own Cluster.**
40+
41+
For more information, see [Set Up Development Environments for Testing](/vendor/environment-setup#dev).
42+
43+
## Tutorial
44+
45+
1. Create an application using the Replicated CLI:
46+
47+
1. On your local machine, install the Replicated CLI:
48+
49+
* MacOS
50+
51+
```bash
52+
brew install replicatedhq/replicated/cli
53+
```
54+
* Linux / Windows Subsystem for Linux (WSL)
55+
56+
```bash
57+
version=$(curl -s https://api.github.com/repos/replicatedhq/replicated/releases/latest \
58+
| grep -m1 -Po '"tag_name":\s*"v\K[^"]+')
59+
curl -Ls \
60+
"https://github.com/replicatedhq/replicated/releases/download/v${version}/replicated_${version}_linux_amd64.tar.gz" \
61+
-o replicated.tar.gz
62+
tar xf replicated.tar.gz replicated && rm replicated.tar.gz
63+
mv replicated /usr/local/bin/replicated
64+
```
65+
For more information and additional installation options, see [Install the Replicated CLI](/reference/replicated-cli-installing).
66+
67+
1. Authorize the Replicated CLI:
68+
69+
```bash
70+
replicated login
71+
```
72+
In the browser window that opens, follow the prompt to log in to your Vendor Portal account and authorize the CLI.
73+
74+
1. Create an application named `SlackerNews`:
75+
76+
```bash
77+
replicated app create SlackerNews
78+
```
79+
80+
1. Set the `REPLICATED_APP` environment variable to the application that you created:
81+
82+
```bash
83+
export REPLICATED_APP=APP_SLUG
84+
```
85+
Where `APP_SLUG` is the unique application slug provided in the output of the `app create` command.
86+
87+
Setting the `REPLICATED_APP` environment variable allows you to interact with the application using the Replicated CLI without needing to use the `--app` flag with every command.
88+
89+
1. Get the sample SlackerNews Helm chart:
90+
91+
1. Run the following command to download version 1.0.0 of the sample SlackerNews Helm chart to a new `quick-start` directory:
92+
93+
```
94+
curl -O --create-dirs --output-dir quick-start https://docs.replicated.com/slackernews-1.0.0.tar.gz
95+
```
96+
97+
1. Untar the chart:
98+
99+
```
100+
tar -xzf quick-start/slackernews-1.0.0.tar.gz -C quick-start/ && rm quick-start/slackernews-1.0.0.tar.gz
101+
```
102+
103+
1. Change to the `slackernews` chart directory:
104+
105+
```bash
106+
cd quick-start/chart/slackernews
107+
```
108+
109+
1. List the files in the `slackernews` directory to view the contents of the Helm chart:
110+
```bash
111+
ls
112+
```
113+
```bash
114+
Chart.lock Chart.yaml NOTES.txt README.md templates values.yaml
115+
```
116+
117+
1. In the SlackerNews Helm chart `Chart.yaml`, add the Replicated SDK as a dependency:
118+
119+
<DependencyYaml/>
120+
121+
The Replicated SDK is a Helm chart that provides access to Replicated features and can be installed as a small service alongside your application. For more information, see [About the Replicated SDK](/vendor/replicated-sdk-overview).
122+
123+
adds preflight checks to the application:
124+
125+
1. In your local filesystem, go to the `quick-start/chart/slackernews` directory.
126+
127+
1. Create a `preflights.yaml` file in the `templates` directory for the chart:
128+
129+
```
130+
touch templates/preflights.yaml
131+
```
132+
133+
1. In the `preflights.yaml` file, add the following YAML to create a Kubernetes Secret with a simple preflight spec:
134+
135+
```yaml
136+
apiVersion: v1
137+
kind: Secret
138+
metadata:
139+
name: slackernews-preflight
140+
labels:
141+
troubleshoot.sh/kind: preflight
142+
stringData:
143+
preflight.yaml: |-
144+
apiVersion: troubleshoot.sh/v1beta2
145+
kind: Preflight
146+
metadata:
147+
name: slackernews-preflight
148+
spec:
149+
collectors:
150+
- clusterInfo: {}
151+
- clusterResources: {}
152+
- http:
153+
collectorName: slack
154+
get:
155+
url: https://api.slack.com/methods/api.test
156+
timeout: 20s
157+
analyzers:
158+
# verify that slack is accessible
159+
- textAnalyze:
160+
checkName: Slack Accessible
161+
fileName: slack.json
162+
regex: '"status": 200,'
163+
outcomes:
164+
- pass:
165+
when: "true"
166+
message: "Can access the Slack API"
167+
- fail:
168+
when: "false"
169+
message: "Cannot access the Slack API. Check that the server can reach the internet and check [status.slack.com](https://status.slack.com)."
170+
```
171+
172+
The YAML above defines a preflight check that confirms that an HTTP request to the Slack API at `https://api.slack.com/methods/api.test` made from the cluster returns a successful response of `"status": 200,`.
173+
174+
1. In the `Chart.yaml` file, increment the version to 1.0.1:
175+
176+
```yaml
177+
# Chart.yaml
178+
version: 1.0.1
179+
```
180+
181+
1. Update dependencies and package the Helm chart to a `.tgz` chart archive:
182+
183+
```bash
184+
helm package --dependency-update .
185+
```
186+
Where `--dependency-update` (or `-u`) is an option for the `helm package` command that updates chart dependencies before packaging. For more information, see [Helm Package](https://helm.sh/docs/helm/helm_package/) in the Helm documentation.
187+
188+
The output of this command is a file named `slackernews-1.0.0.tgz`.
189+
190+
1. Add the chart to a new release with `replicated release create --yaml-dir . --promote Unstable`.
191+
192+
1. Create a customer:
193+
194+
1. Log in to the [Vendor Portal](https://vendor.replicated.com).
195+
196+
1. Under the application drop down, select the SlackerNews application that you created.
197+
198+
<img alt="App drop down" src="/images/quick-start-app-dropdown-slackernews.png" width="250px"/>
199+
200+
[View a larger version of this image](/images/quick-start-app-dropdown-slackernews.png)
201+
202+
1. Click **Customers > Create customer**.
203+
204+
The **Create a new customer** page opens:
205+
206+
![Customer a new customer page in the Vendor Portal](/images/create-customer.png)
207+
208+
[View a larger version of this image](/images/create-customer.png)
209+
210+
1. For **Customer name**, enter a name for the customer. For example, `Example Customer`.
211+
212+
1. For **Assigned Channel**, select **Unstable**. This allows the customer to install releases promoted to the Unstable channel.
213+
214+
1. For **Customer type**, select **Development**.
215+
216+
1. For **Install types**, enable **Existing Cluster (Helm CLI)**.
217+
218+
1. Click **Save Changes**.
219+
220+
1. Access the Enterprise Portal for the customer to get the Helm CLI installatio instructions:
221+
222+
1. On the customer's page, go to the **Enterprise Portal Access** tab.
223+
224+
1. Enable the **Enable Enterprise Portal for this customer** toggle.
225+
226+
![enterprise portal toggle enabled](/images/customer-enterprise-portal-access-toggle.png)
227+
228+
[View a larger version of this image](/images/customer-enterprise-portal-access-toggle.png)
229+
230+
:::note
231+
The Enterprise Portal is beta. By default, customers are assigned access to the Replicated Download Portal. For more information, see [Comparison to the Download Portal](/vendor/enterprise-portal-about#comparison-to-the-download-portal) in _About the Enterprise Portal_.
232+
:::
233+
234+
1. In the **Invite users** dialog, enter your work email address and click **Send invite**.
235+
236+
For your production application, this is where you would invite your customers to access the Enterprise Portal.
237+
238+
1. In your inbox, open the **Invitation to join the Replicated Enterprise Portal** email and click **Activate your account**.
239+
240+
![invitation email](/images/enterprise-portal-invitation-email.png)
241+
242+
[View a larger version of this image](/images/enterprise-portal-invitation-email.png)
243+
244+
1. On the join page, click **Accept invite**.
245+
246+
![join page](/images/enterprise-portal-join-team.png)
247+
248+
[View a larger version of this image](/images/enterprise-portal-join-team.png)
249+
250+
The Enterprise Portal dashboard opens.
251+
252+
1. Go to the **Install** tab.
253+
254+
![install tab](/images/enterprise-portal-install-tab.png)
255+
256+
[View a larger version of this image](/images/enterprise-portal-install-tab.png)
257+
258+
1. On the **Installation Guide** page, if multiple installation options are displayed, select **Helm**.
259+
260+
The installation options that are displayed in the Enterprise Portal depend on the **Install types** options that you enabled for the customer.
261+
262+
![installation guide landing page](/images/enterprise-portal-installation-guide.png)
263+
264+
[View a larger version of this image](/images/enterprise-portal-installation-guide.png)
265+
266+
1. For instance name, enter a nickname for the instance.
267+
268+
1. For **Kubernetes Distribution**, select the distribution of your cluster where you will install SlackerNews.
269+
270+
1. For **Cluster Network Availability**, select **Outbound requests allowed**.
271+
272+
1. For **Registry Access**, select **My workstation can access the internet, the registry AND the cluster**.
273+
274+
1. Click **Next**.
275+
276+
1. Access your cluster. If you are using Compatibility Matrix, do the following:
277+
278+
1. Create a kind cluster with version 1.34.0 of Kubernetes:
279+
280+
```bash
281+
replicated cluster create --distribution kind --instance-type r1.small --disk 50 --version 1.34.0
282+
```
283+
284+
1. After the cluster is running, use the kubectl command provided to set your kubectl context to the cluster.
285+
286+
1. Go back to the Enterprise Portal installation guide to get the installation commands:
287+
288+
1. For **Helm Online Install**, select the release version that you promoted (`0.0.1`).
289+
290+
1. Copy and run the first command to log in to the Replicated registry.
291+
292+
1. Copy and run the commands to install and run preflight checks.
293+
294+
1. Create a values file to set the domain for the SlackerNews application.
295+
296+
```bash
297+
touch my-values.yaml
298+
```
299+
1. In the `my-values.yaml` file, copy and paste the following YAML:
300+
301+
<details>
302+
<summary>View `my-values.yaml`</summary>
303+
```yaml
304+
postgres:
305+
# tells slackernews to use postgres as the
306+
# backing database instead of sqlite
307+
enabled: false
308+
# deploys a postgresql workload to the cluster
309+
deploy_postgres: false
310+
# the password to use with deploy_postgres
311+
password: ""
312+
# if deploy_postgres is false, provide a URI
313+
uri: ""
314+
# use a value in an existing secret instead of
315+
# .postgres.password OR .postgres.uri
316+
existingSecretName: ""
317+
# key in the secret that contains the password
318+
existingSecretPasswordKey: ""
319+
# key in the secret that contains the uri
320+
existingSecretUriKey: ""
321+
# service type if deploy_postgres is true
322+
service:
323+
type: ClusterIP
324+
nodePort:
325+
port:
326+
sqlite:
327+
enabled: true
328+
ingress:
329+
annotations: {}
330+
enabled: false
331+
ingressClassName: ""
332+
nginx:
333+
service:
334+
type: ClusterIP
335+
nodePort:
336+
port:
337+
service:
338+
tls:
339+
enabled: false
340+
existingSecretName: ""
341+
existingSecretCertKey: ""
342+
existingSecretKeyKey: ""
343+
cert: ""
344+
key: ""
345+
slack:
346+
clientId: ""
347+
clientSecret: ""
348+
userToken: ""
349+
botToken: ""
350+
existingSecretName: ""
351+
existingSecretClientIdKey: ""
352+
existingSecretClientSecretKey: ""
353+
existingSecretUserTokenKey: ""
354+
existingSecretBotTokenKey: ""
355+
slackernews:
356+
domain: ""
357+
# set default admin users
358+
adminUserEmails: ""
359+
# display running version on admin dashboard
360+
version: "$TAG"
361+
replicated:
362+
isEmbeddedCluster: false
363+
image:
364+
registry: registry.replicated.com
365+
repository: library/replicated-sdk-image
366+
tag: 1.8.0
367+
images:
368+
pullSecrets:
369+
- name: slackernews-pull-secret
370+
slackernews:
371+
registry: us-docker.pkg.dev
372+
repository: smart-proxy-839/slackernews/slackernews-web
373+
tag: v1.0.36
374+
pullPolicy: IfNotPresent
375+
nginx:
376+
registry: index.docker.io
377+
repository: library/nginx
378+
tag: 1.28.0
379+
pullPolicy: IfNotPresent
380+
postgres:
381+
registry: index.docker.io
382+
repository: library/postgres
383+
tag: 16
384+
pullPolicy: IfNotPresent
385+
```
386+
</details>
387+
388+
1. In the `my-values.yaml` file, enter a hostname in the `slackernews.domain` field.
389+
390+
1. Run the install command to install SlackerNews in your cluster using the Helm CLI.
391+
392+
1. Run `kubectl get all -n slackernews` to see when services are running
393+
394+
1. Run `kubectl port-forward --namespace slackernews svc/slackernews-nginx 8080:80` to port forward
395+
396+
1. Open `localhost:8080` in a browser.
82.8 KB
Loading
304 KB
Loading
58.1 KB
Loading
271 KB
Loading
102 KB
Loading

0 commit comments

Comments
 (0)