Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit e53ed73

Browse files
authored
reform the kubernetes docs (#1678)
1 parent 8d8abf8 commit e53ed73

File tree

3 files changed

+115
-94
lines changed

3 files changed

+115
-94
lines changed

content/en/user-guide/integrations/kubernetes/index.md

Lines changed: 27 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -54,98 +54,44 @@ Some useful Helm client commands are:
5454
- View available charts: `helm search repo`
5555
- Install a chart: `helm install <name> localstack/<chart>`
5656
- Upgrade your application: `helm upgrade`
57+
- Uninstall or delete a release: `helm uninstall <name>`
5758

58-
## LocalStack on Kubernetes (`l8k`)
59+
## LocalStack Pro
5960

60-
The [`localstack-on-k8s`](https://github.com/localstack/localstack-on-k8s) sample repository illustrates running LocalStack on Kubernetes (k8s).
61+
You can use this chart with LocalStack Pro by:
6162

62-
### Prerequisites
63-
64-
This sample requires the following tools installed on your machine:
65-
66-
- Python 3.7+
67-
- [`awslocal`](https://github.com/localstack/awscli-local)
68-
- [Docker](https://www.docker.com)
69-
- [Git](https://git-scm.com)
70-
- [Helm](https://helm.sh)
71-
- [`kubectl`](https://kubernetes.io/docs/tasks/tools/#kubectl)
72-
- [Serverless](https://www.npmjs.com/package/serverless)
73-
74-
### Clone the sample repository
63+
1. Changing the image to `localstack/localstack-pro`.
64+
2. Providing your Auth Token as an environment variable.
7565

76-
Clone the repository:
77-
78-
{{< command >}}
79-
$ git@github.com:localstack/localstack-on-k8s.git
80-
{{< /command >}}
66+
You can set these values in a YAML file (in this example `pro-values.yaml`):
8167

82-
To install the Python dependencies in a virtualenv:
68+
```yaml
69+
image:
70+
repository: localstack/localstack-pro
8371

84-
{{< command >}}
85-
$ make install
86-
{{< /command >}}
72+
extraEnvVars:
73+
- name: LOCALSTACK_AUTH_TOKEN
74+
value: "<your auth token>"
75+
```
8776
88-
To create an embedded Kubernetes (k3d) cluster in Docker and install LocalStack in it (via Helm):
77+
If you have the LocalStack Auth Token in a secret, you can also reference it directly with `extraEnvVars`:
8978

90-
{{< command >}}
91-
$ make init
92-
{{< /command >}}
79+
```yaml
80+
extraEnvVars:
81+
- name: LOCALSTACK_AUTH_TOKEN
82+
valueFrom:
83+
secretKeyRef:
84+
name: <name of the secret>
85+
key: <name of the key in the secret containing the API key>
86+
```
9387

94-
After initialization, your `kubectl` command-line should be automatically configured to point to the local cluster context:
88+
And you can use these values when installing the chart in your cluster:
9589

9690
{{< command >}}
97-
$ kubectl config current-context
98-
<disable-copy>
99-
k3d-ls-cluster
100-
</disable-copy>
91+
$ helm repo add localstack-charts https://localstack.github.io/helm-charts
92+
$ helm install my-release localstack-charts/localstack -f pro-values.yaml
10193
{{< /command >}}
10294

103-
### Deploy the sample application
104-
105-
Once LocalStack is installed in the Kubernetes cluster, we can deploy the sample app on the LocalStack instance:
106-
107-
{{< command >}}
108-
$ make deploy
109-
{{< /command >}}
110-
111-
### Test the sample application
112-
113-
Once the sample app is deployed, the Kubernetes environment should contain the following resources:
114-
115-
{{< command >}}
116-
$ kubectl get all
117-
NAME READY STATUS RESTARTS AGE
118-
pod/localstack-6fd5b98f59-zcx2t 1/1 Running 0 5m
119-
120-
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
121-
service/kubernetes ClusterIP 10.43.0.1 <none> 443/TCP 5m
122-
service/localstack NodePort 10.43.100.167 <none> 4566:31566/TCP,4571:31571/TCP 5m
123-
124-
NAME READY UP-TO-DATE AVAILABLE AGE
125-
deployment.apps/localstack 1/1 1 1 5m
126-
127-
NAME DESIRED CURRENT READY AGE
128-
replicaset.apps/localstack-6fd5b98f59 1 1 1 5m
129-
{{< /command >}}
130-
131-
The LocalStack instance should be available via the local ingress port `8081`.
132-
We can verify that the resources were successfully created by running a few `awslocal` commands against the local endpoint:
133-
134-
{{< command >}}
135-
$ awslocal sqs --endpoint-url=http://localhost:8081 list-queues
136-
{
137-
"QueueUrls": [
138-
"http://localhost:8081/000000000000/requestQueue"
139-
]
140-
}
141-
$ awslocal apigateway --endpoint-url=http://localhost:8081 get-rest-apis
142-
{
143-
"items": [
144-
{
145-
"id": "ses2pi5oap",
146-
"name": "local-localstack-demo",
147-
...
148-
{{< /command >}}
95+
## Parameters
14996

150-
We can then use a browser to open the [Web UI](http://localhost:8081/archive-bucket/index.html), which should have been deployed to an S3 bucket inside LocalStack.
151-
The Web UI can be used to interact with the sample application, send new requests to the backend, inspect the state of existing requests, etc.
97+
{{< github-markdown repo="localstack/helm-charts" file="charts/localstack/README.md#parameters" lang="markdown" >}}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{{ $repo := .Get "repo" }}
2+
{{ $file := .Get "file" }}
3+
{{ $ref := .Get "ref" }}
4+
5+
{{ $fileUrl := $file }}
6+
{{ $section := "" }}
7+
{{ if findRE "#" $file 1 }}
8+
{{ $fileParts := split $file "#" }}
9+
{{ $fileUrl = index $fileParts 0 }}
10+
{{ $section = index $fileParts 1 }}
11+
{{ end }}
12+
13+
{{ $url := printf "https://api.github.com/repos/%s/contents/%s" $repo $fileUrl }}
14+
{{ if $ref }}
15+
{{ $url = printf "%s?ref=%s" $url $ref }}
16+
{{ end }}
17+
18+
{{ $headers := dict "Accept" "application/vnd.github.v3.raw" }}
19+
{{ $resp := resources.GetRemote $url (dict "headers" $headers) }}
20+
21+
{{ if not $resp }}
22+
{{ errorf "Failed to fetch content from GitHub: %s" $url }}
23+
{{ end }}
24+
25+
{{ $content := $resp.Content }}
26+
27+
{{ if $section }}
28+
{{ $lines := split $content "\n" }}
29+
{{ $sectionContent := slice }}
30+
{{ $inSection := false }}
31+
{{ $sectionLevel := 0 }}
32+
33+
{{ range $lines }}
34+
{{ $line := . }}
35+
{{ if not $inSection }}
36+
{{ $headingMatch := findRE (printf "^(#+)\\s+.*%s.*$" $section) $line 1 }}
37+
{{ if $headingMatch }}
38+
{{ $heading := index $headingMatch 0 }}
39+
{{ $levelMatch := findRE "^(#+)" $heading 1 }}
40+
{{ $sectionLevel = len (index $levelMatch 0) }}
41+
{{ $inSection = true }}
42+
{{ $sectionContent = $sectionContent | append $line }}
43+
{{ end }}
44+
{{ else }}
45+
{{ $nextHeadingMatch := findRE "^(#+)\\s+" $line 1 }}
46+
{{ if $nextHeadingMatch }}
47+
{{ $nextLevel := len (index $nextHeadingMatch 0) }}
48+
{{ if le $nextLevel $sectionLevel }}
49+
{{ $inSection = false }}
50+
{{ else }}
51+
{{ $sectionContent = $sectionContent | append $line }}
52+
{{ end }}
53+
{{ else }}
54+
{{ $sectionContent = $sectionContent | append $line }}
55+
{{ end }}
56+
{{ end }}
57+
{{ end }}
58+
59+
{{ if len $sectionContent }}
60+
{{ $content = delimit $sectionContent "\n" }}
61+
{{ end }}
62+
{{ end }}
63+
64+
{{ $content | markdownify }}

layouts/shortcodes/github.html

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1-
{{ $ref := "" }}
2-
{{ if (.Get "ref") }}
3-
{{ $ref = printf "?ref=%s" (.Get "ref") }}
1+
{{ $repo := .Get "repo" }}
2+
{{ $file := .Get "file" }}
3+
{{ $ref := .Get "ref" }}
4+
{{ $start := .Get "start" | default 1 | int }}
5+
{{ $end := .Get "end" | default 999999 | int }}
6+
{{ $lang := .Get "lang" }}
7+
{{ $options := .Get "options" }}
8+
9+
{{ $url := printf "https://api.github.com/repos/%s/contents/%s" $repo $file }}
10+
{{ if $ref }}
11+
{{ $url = printf "%s?ref=%s" $url $ref }}
412
{{ end }}
5-
{{ $json := resources.GetRemote "https://api.github.com/repos/" (.Get "repo") "/contents/" (.Get "file") $ref }}
6-
{{ $data := $json | transform.Unmarshal }}
7-
{{ $con := base64Decode $data.content }}
8-
{{ $content := "" }}
9-
{{ $lines := split $con "\n" }}
10-
{{ $startIndex := (sub ((.Get "start") | default 1 | int) 1)}}
11-
{{ $endIndex := (.Get "end" | default "999999" | int )}}
12-
{{ range $line := (last (sub $endIndex $startIndex) (first $endIndex $lines)) }}
13-
{{ $content = printf "%s\n%s" $content $line }}
13+
14+
{{ $headers := dict "Accept" "application/vnd.github.v3.raw" }}
15+
{{ $resp := resources.GetRemote $url (dict "headers" $headers) }}
16+
17+
{{ if not $resp }}
18+
{{ errorf "Failed to fetch content from GitHub: %s" $url }}
1419
{{ end }}
15-
{{ highlight $content (.Get "lang") (.Get "options") }}
20+
21+
{{ $lines := split $resp.Content "\n" }}
22+
{{ $startIndex := sub $start 1 }}
23+
{{ $linesToShow := last (sub $end $startIndex) (first $end $lines) }}
24+
25+
{{ $content := delimit $linesToShow "\n" }}
26+
{{ highlight $content $lang $options }}

0 commit comments

Comments
 (0)