Skip to content

Commit 7d6604f

Browse files
authored
Merge pull request #473 from rawmind0/appv2
Add new Rancher 2.5 app v2 support
2 parents 43f2840 + 6a58e1b commit 7d6604f

30 files changed

Lines changed: 1938 additions & 518 deletions

CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 1.10.4 (Unreleased)
1+
## 1.10.4 (October 29, 2020)
22

33
FEATURES:
44

@@ -12,17 +12,19 @@ FEATURES:
1212
* **New Argument:** `rancher2_bootstrap.ui_default_landing` - (Optional) Set default ui landing on Rancher bootstrap. Just for Rancher v2.5.0 and above
1313
* **New Data Source:** `rancher2_catalog_v2` - Support new Rancher catalog V2 datasource. Just for Rancher v2.5.0 and above
1414
* **New Resource:** `rancher2_catalog_v2` - Support new Rancher catalog V2 resource. Just for Rancher v2.5.0 and above
15+
* **New Resource:** `rancher2_app_v2` - Support new Rancher app V2 resource. Just for Rancher v2.5.0 and above
1516

1617
ENHANCEMENTS:
1718

1819
* Added new computed `ca_cert` argument at `rancher2_cluster` resource and datasource
19-
* Updated acceptance tests to use k3s `v1.18.9-k3s1` and cert-manager `v1.0.1`
2020
* Delete `rancher2_app` if created and got timeout to be active
2121
* Updated golang to v1.14.9 and removing vendor folder
22-
* Updated go mod to support Rancher `v2.5.0`
22+
* Updated go mod to support Rancher `v2.5.1`
2323
* Added dingtal_config and msteams_config arguments at rancher2_notifier resource. go code and docs
2424
* Improved `rancher2_cluster_sync` wait for cluster monitoring
2525
* Improved `rancher2_bootstrap` on resource creation. `bootstrapDoLogin` function will retry 3 times user/pass login before fail
26+
* Updated acceptance tests to use Rancher `v2.5.1`, k3s `v1.18.9-k3s1` and cert-manager `v1.0.1`
27+
* Added new `Apps & marketplace` guide for Rancher v2.5.0
2628

2729
BUG FIXES:
2830

docs/data-sources/catalog_v2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ Use this data source to retrieve information about a Rancher2 catalog v2.
1010

1111
```
1212
data "rancher2_catalog_v2" "foo" {
13-
cluster_id = "<CLUSTER_ID>"
13+
cluster_id = <CLUSTER_ID>
1414
name = "foo"
1515
}
1616
```
1717

1818
## Argument Reference
1919

20-
* `cluster_id` - (Required) The cluster id of the catalog (string)
20+
* `cluster_id` - (Required) The cluster id of the catalog V2 (string)
2121
* `name` - (Required) The name of the catalog v2 (string)
2222

2323
## Attributes Reference

docs/guides/apps_marketplace.md

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
---
2+
page_title: "Apps & Marketplace"
3+
---
4+
5+
# Apps & Marketplace
6+
7+
Apps & Marketplace is a new Rancher 2.5 feature, to manage Helm chart repositories and applications in Rancher. The feature is available at Rancher `Cluster Explorer` UI, and is controlled by 2 objects:
8+
9+
* Repositories: These object represent helm repositories, and can be either traditional helm endpoints which have an index.yaml, or git repositories which will be cloned and can point to a specific branch.
10+
* Charts: These object represent helm charts contained at all Rancher, Partner and Custom repositories. Rancher tools such as Logging or Monitoring are included under the Rancher label
11+
12+
More info at [Rancher Apps & Marketplace](https://rancher.com/docs/rancher/v2.x/en/helm-charts/apps-marketplace/)
13+
14+
## New provider resources
15+
16+
To support this new feature on this terraform provider, 2 new resources has been added:
17+
* `rancher2_catalog_v2` - To support repository object
18+
* `rancher2_app_v2` - To support chart object
19+
20+
21+
## rancher2_catalog_v2
22+
23+
This resource has the following arguments definition:
24+
25+
* `cluster_id` - (Required/ForceNew) The cluster id of the catalog V2 (string)
26+
* `name` - (Required) The name of the catalog v2 (string)
27+
* `ca_bundle` - (Optional) PEM encoded CA bundle which will be used to validate the repo's certificate (string)
28+
* `enabled` - (Optional) If disabled the repo clone will not be updated or allowed to be installed from. Default: `true` (bool)
29+
* `git_branch` - (Optional) Git Repository branch containing Helm chart definitions. Default `master` (string)
30+
* `git_repo` - (Optional) The url of the catalog v2 repo (string)
31+
* `insecure` - (Optional) Use insecure HTTPS to download the repo's index. Default: `false` (bool)
32+
* `secret_name` - (Optional) K8s secret name to be used to connect to the repo (string)
33+
* `secret_namespace` - (Optional) K8s secret namespace (string)
34+
* `service_account` - (Optional) K8s service account used to deploy charts instead of the end users credentials (string)
35+
* `service_account_namespace` - (Optional) The username to access the catalog if needed (string)
36+
* `url` - (Optional) URL to an index generated by Helm (string)
37+
* `annotations` - (Optional/Computed) Annotations for the catalog v2 (map)
38+
* `labels` - (Optional/Computed) Labels for the catalog v2 (map)
39+
40+
### Examples
41+
42+
These are some examples how to use a new catalog v2:
43+
44+
* Create new repository using git repo and branch
45+
```
46+
resource "rancher2_catalog_v2" "foo" {
47+
cluster_id = "<CLUSTER_ID>""
48+
name = "foo"
49+
git_repo = "<GIT_REPO_URL>"
50+
git_branch = "<GIT_BRANCH>"
51+
}
52+
```
53+
54+
* Create new repository using http url
55+
```
56+
resource "rancher2_catalog_v2" "foo-url" {
57+
cluster_id = "<CLUSTER_ID>"
58+
name = "foo-url"
59+
url = "https://<CATALOG_URL>"
60+
}
61+
```
62+
63+
* Import existing repository
64+
65+
```
66+
## Define catalog at tf file
67+
resource "rancher2_catalog_v2" "rancher-charts" {
68+
cluster_id = "<CLUSTER_ID>"
69+
name = "rancher-charts"
70+
git_repo = "https://git.rancher.io/charts"
71+
git_branch = "main"
72+
}
73+
## Import the catalog v2 data to tfstate
74+
# terraform import rancher2_catalog_v2.rancher-charts rancher-charts
75+
```
76+
77+
* Using datasource
78+
79+
```
80+
data "rancher2_catalog_v2" "foo" {
81+
cluster_id = "<CLUSTER_ID>"
82+
name = "foo"
83+
}
84+
```
85+
86+
## rancher2_app_v2
87+
88+
This resource has the following arguments definition:
89+
90+
* `cluster_id` - (Required/ForceNew) The cluster id of the app (string)
91+
* `name` - (Required/ForceNew) The name of the app v2 (string)
92+
* `namespace` - (Required/ForceNew) The namespace of the app v2 (string)
93+
* `repo_name` - (Required) Repo name (string)
94+
* `chart_name` - (Required) The app v2 chart name (string)
95+
* `chart_version` - (Optional) The app v2 chart version (string)
96+
* `project_id` - (Optional) Deploy the app v2 within project ID (string)
97+
* `values` - (Optional) The app v2 values yaml. Yaml format is required (string)
98+
* `cleanup_on_fail` - (Optional) Cleanup app v2 on failed chart upgrade. Default: `false` (bool)
99+
* `disable_hooks` - (Optional) Disable app v2 chart hooks. Default: `false` (bool)
100+
* `disable_open_api_validation` - (Optional) Disable app V2 Open API Validation. Default: `false` (bool)
101+
* `force_upgrade` - (Optional) Force app V2 chart upgrade. Default: `false` (bool)
102+
* `wait` - (Optional) Wait until app is deployed. Default: `false` (bool)
103+
* `annotations` - (Optional/Computed) Annotations for the app v2 (map)
104+
* `labels` - (Optional/Computed) Labels for the app v2 (map)
105+
106+
### Examples
107+
108+
These are some examples how to deploy some Rancher cerfified apps v2:
109+
110+
* Deploy Rancher monitoring
111+
112+
```
113+
resource "rancher2_app_v2" "rancher-monitoring" {
114+
cluster_id = "<CLUSTER_ID>"
115+
name = "rancher-monitoring"
116+
namespace = "cattle-monitoring-system"
117+
repo_name = "rancher-charts"
118+
chart_name = "rancher-monitoring"
119+
chart_version = "9.4.200"
120+
values = <<EOF
121+
prometheus:
122+
prometheusSpec:
123+
requests:
124+
cpu: "250m"
125+
memory: "250Mi"
126+
EOF
127+
}
128+
```
129+
130+
** tip ** If you are reinstalling `rancher-monitoring` and the deployment is failing, try adding this values to app v2
131+
```
132+
alertmanager:
133+
alertmanagerSpec:
134+
enabled: false
135+
useExistingSecret: true
136+
configSecret: alertmanager-rancher-monitoring-alertmanager
137+
```
138+
139+
* Deploy Rancher istio and Rancher monitoring as requirement
140+
141+
```
142+
resource "rancher2_app_v2" "rancher-monitoring" {
143+
cluster_id = "<CLUSTER_ID>"
144+
name = "rancher-monitoring"
145+
namespace = "cattle-monitoring-system"
146+
repo_name = "rancher-charts"
147+
chart_name = "rancher-monitoring"
148+
chart_version = "9.4.200"
149+
values = <<EOF
150+
prometheus:
151+
prometheusSpec:
152+
requests:
153+
cpu: "250m"
154+
memory: "250Mi"
155+
EOF
156+
}
157+
158+
resource "rancher2_app_v2" "rancher-istio" {
159+
depends_on = [rancher2_app_v2.rancher-monitoring] # Rancher-istio requires rancher-monitoring
160+
161+
cluster_id = "<CLUSTER_ID>"
162+
name = "rancher-istio"
163+
namespace = "istio-system"
164+
repo_name = "rancher-charts"
165+
chart_name = "rancher-istio"
166+
chart_version = "1.7.100"
167+
}
168+
```
169+
170+
* Deploy Rancher cis benchmark
171+
172+
```
173+
resource "rancher2_app_v2" "rancher-cis-benchmark" {
174+
cluster_id = "<CLUSTER_ID>"
175+
name = "rancher-cis-benchmark"
176+
namespace = "istio-system"
177+
repo_name = "rancher-charts"
178+
chart_name = "rancher-cis-benchmark"
179+
chart_version = "1.0.100"
180+
wait = true
181+
}
182+
```
183+
184+
* Deploy Rancher backup
185+
186+
```
187+
resource "rancher2_app_v2" "rancher-backup" {
188+
cluster_id = "<CLUSTER_ID>"
189+
name = "rancher-backup"
190+
namespace = "cattle-resources-system"
191+
repo_name = "rancher-charts"
192+
chart_name = "rancher-backup"
193+
chart_version = "1.0.200"
194+
values = <<EOF
195+
persistence:
196+
enabled: false
197+
size: 2Gi
198+
storageClass: '-'
199+
volumeName: ""
200+
s3:
201+
bucketName: ""
202+
credentialSecretName: ""
203+
credentialSecretNamespace: ""
204+
enabled: false
205+
endpoint: ""
206+
endpointCA: ""
207+
folder: ""
208+
insecureTLSSkipVerify: false
209+
region: ""
210+
EOF
211+
wait = true
212+
}
213+
```
214+
215+
* Deploy Rancher logging
216+
217+
```
218+
resource "rancher2_app_v2" "rancher-logging" {
219+
cluster_id = "<CLUSTER_ID>"
220+
name = "rancher-logging"
221+
namespace = "cattle-logging-system"
222+
repo_name = "rancher-charts"
223+
chart_name = "rancher-logging"
224+
chart_version = "3.6.000"
225+
wait = true
226+
}
227+
```

docs/resources/app_v2.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
page_title: "Rancher2: rancher2_catalog_v2 Resource"
3+
---
4+
5+
# rancher2\_app\_v2 Resource
6+
7+
Provides a Rancher App v2 resource. This can be used to manage helm charts for Rancher v2 environments and retrieve their information. App v2 resource is available at Rancher v2.5.x and above.
8+
9+
## Example Usage
10+
11+
```hcl
12+
# Create a new Rancher2 App V2 using
13+
resource "rancher2_app_v2" "foo" {
14+
cluster_id = "<CLUSTER_ID>"
15+
name = "rancher-monitoring"
16+
namespace = "cattle-monitoring-system"
17+
repo_name = "rancher-charts"
18+
chart_name = "rancher-monitoring"
19+
chart_version = "9.4.200"
20+
values = file("values.yaml")
21+
}
22+
```
23+
24+
## Argument Reference
25+
26+
The following arguments are supported:
27+
28+
* `cluster_id` - (Required/ForceNew) The cluster id of the app (string)
29+
* `name` - (Required/ForceNew) The name of the app v2 (string)
30+
* `namespace` - (Required/ForceNew) The namespace of the app v2 (string)
31+
* `repo_name` - (Required) Repo name (string)
32+
* `chart_name` - (Required) The app v2 chart name (string)
33+
* `chart_version` - (Optional) The app v2 chart version (string)
34+
* `project_id` - (Optional) Deploy the app v2 within project ID (string)
35+
* `values` - (Optional) The app v2 values yaml. Yaml format is required (string)
36+
* `cleanup_on_fail` - (Optional) Cleanup app v2 on failed chart upgrade. Default: `false` (bool)
37+
* `disable_hooks` - (Optional) Disable app v2 chart hooks. Default: `false` (bool)
38+
* `disable_open_api_validation` - (Optional) Disable app V2 Open API Validation. Default: `false` (bool)
39+
* `force_upgrade` - (Optional) Force app V2 chart upgrade. Default: `false` (bool)
40+
* `wait` - (Optional) Wait until app is deployed. Default: `false` (bool)
41+
* `annotations` - (Optional/Computed) Annotations for the app v2 (map)
42+
* `labels` - (Optional/Computed) Labels for the app v2 (map)
43+
44+
## Attributes Reference
45+
46+
The following attributes are exported:
47+
48+
* `id` - (Computed) The ID of the resource (string)
49+
* `cluster_name` - (Computed) The cluster name of the app (string)
50+
51+
## Timeouts
52+
53+
`rancher2_catalog` provides the following
54+
[Timeouts](https://www.terraform.io/docs/configuration/resources.html#operation-timeouts) configuration options:
55+
56+
- `create` - (Default `10 minutes`) Used for creating v2 catalogs.
57+
- `update` - (Default `10 minutes`) Used for v2 catalog modifications.
58+
- `delete` - (Default `10 minutes`) Used for deleting v2 catalogs.
59+
60+
## Import
61+
62+
V2 apps can be imported using the Rancher cluster ID and App V2 name.
63+
64+
```
65+
$ terraform import rancher2_app_v2.foo &lt;CLUSTER_ID&gt;.&lt;APP_V2_NAME&gt;
66+
```

docs/resources/catalog_v2.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ Provides a Rancher Catalog v2 resource. This can be used to create cluster helm
1111
```hcl
1212
# Create a new Rancher2 Catalog V2 using git repo and branch
1313
resource "rancher2_catalog_v2" "foo" {
14-
cluster_id = "<CLUSTER_ID>"
14+
cluster_id = <CLUSTER_ID>
1515
name = "foo"
1616
git_repo = "<GIT_REPO_URL>"
1717
git_branch = "<GIT_BRANCH>"
1818
}
1919
# Create a new Rancher2 Catalog V2 using url
2020
resource "rancher2_catalog_v2" "foo-url" {
21-
cluster_id = "<CLUSTER_ID>"
21+
cluster_id = <CLUSTER_ID>
2222
name = "foo-url"
2323
url = "https://<CATALOG_URL>"
2424
}
@@ -28,7 +28,7 @@ resource "rancher2_catalog_v2" "foo-url" {
2828

2929
The following arguments are supported:
3030

31-
* `cluster_id` - (Required/ForceNew) The cluster id of the catalog (string)
31+
* `cluster_id` - (Required/ForceNew) The cluster id of the catalog V2 (string)
3232
* `name` - (Required) The name of the catalog v2 (string)
3333
* `ca_bundle` - (Optional) PEM encoded CA bundle which will be used to validate the repo's certificate (string)
3434
* `enabled` - (Optional) If disabled the repo clone will not be updated or allowed to be installed from. Default: `true` (bool)
@@ -61,7 +61,7 @@ The following attributes are exported:
6161

6262
## Import
6363

64-
V2 catalogs can be imported using the Rancher Catalog V2 cluster ID and name.
64+
V2 catalogs can be imported using the Rancher cluster ID and Catalog V2 name.
6565

6666
```
6767
$ terraform import rancher2_catalog_v2.foo &lt;CLUSTER_ID&gt;.&lt;CATALOG_V2_NAME&gt;

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/rancher/client-go v11.0.0+incompatible // indirect
1010
github.com/rancher/lasso v0.0.0-20200905045615-7fcb07d6a20b
1111
github.com/rancher/norman v0.0.0-20200930000340-693d65aaffe3
12-
github.com/rancher/rancher v0.0.0-20201006004413-65f3525cdc11
12+
github.com/rancher/rancher v0.0.0-20201007163458-eb990af66be1
1313
github.com/rancher/rancher/pkg/apis v0.0.0
1414
github.com/rancher/rancher/pkg/client v0.0.0
1515
github.com/rancher/wrangler v0.7.2
@@ -23,8 +23,8 @@ require (
2323

2424
replace (
2525
github.com/crewjam/saml => github.com/crewjam/saml v0.4.1
26-
github.com/rancher/rancher/pkg/apis => github.com/rancher/rancher/pkg/apis v0.0.0-20201006004413-65f3525cdc11
27-
github.com/rancher/rancher/pkg/client => github.com/rancher/rancher/pkg/client v0.0.0-20201006004413-65f3525cdc11
26+
github.com/rancher/rancher/pkg/apis => github.com/rancher/rancher/pkg/apis v0.0.0-20201007163458-eb990af66be1
27+
github.com/rancher/rancher/pkg/client => github.com/rancher/rancher/pkg/client v0.0.0-20201007163458-eb990af66be1
2828
k8s.io/api => k8s.io/api v0.19.0
2929
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.19.0
3030
k8s.io/apimachinery => github.com/rancher/apimachinery v0.19.0-rancher1

0 commit comments

Comments
 (0)