Skip to content

Commit

Permalink
Merge pull request #473 from rawmind0/appv2
Browse files Browse the repository at this point in the history
Add new Rancher 2.5 app v2 support
  • Loading branch information
rawmind0 authored Oct 29, 2020
2 parents 43f2840 + 6a58e1b commit 7d6604f
Show file tree
Hide file tree
Showing 30 changed files with 1,938 additions and 518 deletions.
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 1.10.4 (Unreleased)
## 1.10.4 (October 29, 2020)

FEATURES:

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

ENHANCEMENTS:

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

BUG FIXES:

Expand Down
4 changes: 2 additions & 2 deletions docs/data-sources/catalog_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ Use this data source to retrieve information about a Rancher2 catalog v2.

```
data "rancher2_catalog_v2" "foo" {
cluster_id = "<CLUSTER_ID>"
cluster_id = <CLUSTER_ID>
name = "foo"
}
```

## Argument Reference

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

## Attributes Reference
Expand Down
227 changes: 227 additions & 0 deletions docs/guides/apps_marketplace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
---
page_title: "Apps & Marketplace"
---

# Apps & Marketplace

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:

* 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.
* 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

More info at [Rancher Apps & Marketplace](https://rancher.com/docs/rancher/v2.x/en/helm-charts/apps-marketplace/)

## New provider resources

To support this new feature on this terraform provider, 2 new resources has been added:
* `rancher2_catalog_v2` - To support repository object
* `rancher2_app_v2` - To support chart object


## rancher2_catalog_v2

This resource has the following arguments definition:

* `cluster_id` - (Required/ForceNew) The cluster id of the catalog V2 (string)
* `name` - (Required) The name of the catalog v2 (string)
* `ca_bundle` - (Optional) PEM encoded CA bundle which will be used to validate the repo's certificate (string)
* `enabled` - (Optional) If disabled the repo clone will not be updated or allowed to be installed from. Default: `true` (bool)
* `git_branch` - (Optional) Git Repository branch containing Helm chart definitions. Default `master` (string)
* `git_repo` - (Optional) The url of the catalog v2 repo (string)
* `insecure` - (Optional) Use insecure HTTPS to download the repo's index. Default: `false` (bool)
* `secret_name` - (Optional) K8s secret name to be used to connect to the repo (string)
* `secret_namespace` - (Optional) K8s secret namespace (string)
* `service_account` - (Optional) K8s service account used to deploy charts instead of the end users credentials (string)
* `service_account_namespace` - (Optional) The username to access the catalog if needed (string)
* `url` - (Optional) URL to an index generated by Helm (string)
* `annotations` - (Optional/Computed) Annotations for the catalog v2 (map)
* `labels` - (Optional/Computed) Labels for the catalog v2 (map)

### Examples

These are some examples how to use a new catalog v2:

* Create new repository using git repo and branch
```
resource "rancher2_catalog_v2" "foo" {
cluster_id = "<CLUSTER_ID>""
name = "foo"
git_repo = "<GIT_REPO_URL>"
git_branch = "<GIT_BRANCH>"
}
```

* Create new repository using http url
```
resource "rancher2_catalog_v2" "foo-url" {
cluster_id = "<CLUSTER_ID>"
name = "foo-url"
url = "https://<CATALOG_URL>"
}
```

* Import existing repository

```
## Define catalog at tf file
resource "rancher2_catalog_v2" "rancher-charts" {
cluster_id = "<CLUSTER_ID>"
name = "rancher-charts"
git_repo = "https://git.rancher.io/charts"
git_branch = "main"
}
## Import the catalog v2 data to tfstate
# terraform import rancher2_catalog_v2.rancher-charts rancher-charts
```

* Using datasource

```
data "rancher2_catalog_v2" "foo" {
cluster_id = "<CLUSTER_ID>"
name = "foo"
}
```

## rancher2_app_v2

This resource has the following arguments definition:

* `cluster_id` - (Required/ForceNew) The cluster id of the app (string)
* `name` - (Required/ForceNew) The name of the app v2 (string)
* `namespace` - (Required/ForceNew) The namespace of the app v2 (string)
* `repo_name` - (Required) Repo name (string)
* `chart_name` - (Required) The app v2 chart name (string)
* `chart_version` - (Optional) The app v2 chart version (string)
* `project_id` - (Optional) Deploy the app v2 within project ID (string)
* `values` - (Optional) The app v2 values yaml. Yaml format is required (string)
* `cleanup_on_fail` - (Optional) Cleanup app v2 on failed chart upgrade. Default: `false` (bool)
* `disable_hooks` - (Optional) Disable app v2 chart hooks. Default: `false` (bool)
* `disable_open_api_validation` - (Optional) Disable app V2 Open API Validation. Default: `false` (bool)
* `force_upgrade` - (Optional) Force app V2 chart upgrade. Default: `false` (bool)
* `wait` - (Optional) Wait until app is deployed. Default: `false` (bool)
* `annotations` - (Optional/Computed) Annotations for the app v2 (map)
* `labels` - (Optional/Computed) Labels for the app v2 (map)

### Examples

These are some examples how to deploy some Rancher cerfified apps v2:

* Deploy Rancher monitoring

```
resource "rancher2_app_v2" "rancher-monitoring" {
cluster_id = "<CLUSTER_ID>"
name = "rancher-monitoring"
namespace = "cattle-monitoring-system"
repo_name = "rancher-charts"
chart_name = "rancher-monitoring"
chart_version = "9.4.200"
values = <<EOF
prometheus:
prometheusSpec:
requests:
cpu: "250m"
memory: "250Mi"
EOF
}
```

** tip ** If you are reinstalling `rancher-monitoring` and the deployment is failing, try adding this values to app v2
```
alertmanager:
alertmanagerSpec:
enabled: false
useExistingSecret: true
configSecret: alertmanager-rancher-monitoring-alertmanager
```

* Deploy Rancher istio and Rancher monitoring as requirement

```
resource "rancher2_app_v2" "rancher-monitoring" {
cluster_id = "<CLUSTER_ID>"
name = "rancher-monitoring"
namespace = "cattle-monitoring-system"
repo_name = "rancher-charts"
chart_name = "rancher-monitoring"
chart_version = "9.4.200"
values = <<EOF
prometheus:
prometheusSpec:
requests:
cpu: "250m"
memory: "250Mi"
EOF
}
resource "rancher2_app_v2" "rancher-istio" {
depends_on = [rancher2_app_v2.rancher-monitoring] # Rancher-istio requires rancher-monitoring
cluster_id = "<CLUSTER_ID>"
name = "rancher-istio"
namespace = "istio-system"
repo_name = "rancher-charts"
chart_name = "rancher-istio"
chart_version = "1.7.100"
}
```

* Deploy Rancher cis benchmark

```
resource "rancher2_app_v2" "rancher-cis-benchmark" {
cluster_id = "<CLUSTER_ID>"
name = "rancher-cis-benchmark"
namespace = "istio-system"
repo_name = "rancher-charts"
chart_name = "rancher-cis-benchmark"
chart_version = "1.0.100"
wait = true
}
```

* Deploy Rancher backup

```
resource "rancher2_app_v2" "rancher-backup" {
cluster_id = "<CLUSTER_ID>"
name = "rancher-backup"
namespace = "cattle-resources-system"
repo_name = "rancher-charts"
chart_name = "rancher-backup"
chart_version = "1.0.200"
values = <<EOF
persistence:
enabled: false
size: 2Gi
storageClass: '-'
volumeName: ""
s3:
bucketName: ""
credentialSecretName: ""
credentialSecretNamespace: ""
enabled: false
endpoint: ""
endpointCA: ""
folder: ""
insecureTLSSkipVerify: false
region: ""
EOF
wait = true
}
```

* Deploy Rancher logging

```
resource "rancher2_app_v2" "rancher-logging" {
cluster_id = "<CLUSTER_ID>"
name = "rancher-logging"
namespace = "cattle-logging-system"
repo_name = "rancher-charts"
chart_name = "rancher-logging"
chart_version = "3.6.000"
wait = true
}
```
66 changes: 66 additions & 0 deletions docs/resources/app_v2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
page_title: "Rancher2: rancher2_catalog_v2 Resource"
---

# rancher2\_app\_v2 Resource

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.

## Example Usage

```hcl
# Create a new Rancher2 App V2 using
resource "rancher2_app_v2" "foo" {
cluster_id = "<CLUSTER_ID>"
name = "rancher-monitoring"
namespace = "cattle-monitoring-system"
repo_name = "rancher-charts"
chart_name = "rancher-monitoring"
chart_version = "9.4.200"
values = file("values.yaml")
}
```

## Argument Reference

The following arguments are supported:

* `cluster_id` - (Required/ForceNew) The cluster id of the app (string)
* `name` - (Required/ForceNew) The name of the app v2 (string)
* `namespace` - (Required/ForceNew) The namespace of the app v2 (string)
* `repo_name` - (Required) Repo name (string)
* `chart_name` - (Required) The app v2 chart name (string)
* `chart_version` - (Optional) The app v2 chart version (string)
* `project_id` - (Optional) Deploy the app v2 within project ID (string)
* `values` - (Optional) The app v2 values yaml. Yaml format is required (string)
* `cleanup_on_fail` - (Optional) Cleanup app v2 on failed chart upgrade. Default: `false` (bool)
* `disable_hooks` - (Optional) Disable app v2 chart hooks. Default: `false` (bool)
* `disable_open_api_validation` - (Optional) Disable app V2 Open API Validation. Default: `false` (bool)
* `force_upgrade` - (Optional) Force app V2 chart upgrade. Default: `false` (bool)
* `wait` - (Optional) Wait until app is deployed. Default: `false` (bool)
* `annotations` - (Optional/Computed) Annotations for the app v2 (map)
* `labels` - (Optional/Computed) Labels for the app v2 (map)

## Attributes Reference

The following attributes are exported:

* `id` - (Computed) The ID of the resource (string)
* `cluster_name` - (Computed) The cluster name of the app (string)

## Timeouts

`rancher2_catalog` provides the following
[Timeouts](https://www.terraform.io/docs/configuration/resources.html#operation-timeouts) configuration options:

- `create` - (Default `10 minutes`) Used for creating v2 catalogs.
- `update` - (Default `10 minutes`) Used for v2 catalog modifications.
- `delete` - (Default `10 minutes`) Used for deleting v2 catalogs.

## Import

V2 apps can be imported using the Rancher cluster ID and App V2 name.

```
$ terraform import rancher2_app_v2.foo &lt;CLUSTER_ID&gt;.&lt;APP_V2_NAME&gt;
```
8 changes: 4 additions & 4 deletions docs/resources/catalog_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ Provides a Rancher Catalog v2 resource. This can be used to create cluster helm
```hcl
# Create a new Rancher2 Catalog V2 using git repo and branch
resource "rancher2_catalog_v2" "foo" {
cluster_id = "<CLUSTER_ID>"
cluster_id = <CLUSTER_ID>
name = "foo"
git_repo = "<GIT_REPO_URL>"
git_branch = "<GIT_BRANCH>"
}
# Create a new Rancher2 Catalog V2 using url
resource "rancher2_catalog_v2" "foo-url" {
cluster_id = "<CLUSTER_ID>"
cluster_id = <CLUSTER_ID>
name = "foo-url"
url = "https://<CATALOG_URL>"
}
Expand All @@ -28,7 +28,7 @@ resource "rancher2_catalog_v2" "foo-url" {

The following arguments are supported:

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

## Import

V2 catalogs can be imported using the Rancher Catalog V2 cluster ID and name.
V2 catalogs can be imported using the Rancher cluster ID and Catalog V2 name.

```
$ terraform import rancher2_catalog_v2.foo &lt;CLUSTER_ID&gt;.&lt;CATALOG_V2_NAME&gt;
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/rancher/client-go v11.0.0+incompatible // indirect
github.com/rancher/lasso v0.0.0-20200905045615-7fcb07d6a20b
github.com/rancher/norman v0.0.0-20200930000340-693d65aaffe3
github.com/rancher/rancher v0.0.0-20201006004413-65f3525cdc11
github.com/rancher/rancher v0.0.0-20201007163458-eb990af66be1
github.com/rancher/rancher/pkg/apis v0.0.0
github.com/rancher/rancher/pkg/client v0.0.0
github.com/rancher/wrangler v0.7.2
Expand All @@ -23,8 +23,8 @@ require (

replace (
github.com/crewjam/saml => github.com/crewjam/saml v0.4.1
github.com/rancher/rancher/pkg/apis => github.com/rancher/rancher/pkg/apis v0.0.0-20201006004413-65f3525cdc11
github.com/rancher/rancher/pkg/client => github.com/rancher/rancher/pkg/client v0.0.0-20201006004413-65f3525cdc11
github.com/rancher/rancher/pkg/apis => github.com/rancher/rancher/pkg/apis v0.0.0-20201007163458-eb990af66be1
github.com/rancher/rancher/pkg/client => github.com/rancher/rancher/pkg/client v0.0.0-20201007163458-eb990af66be1
k8s.io/api => k8s.io/api v0.19.0
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.19.0
k8s.io/apimachinery => github.com/rancher/apimachinery v0.19.0-rancher1
Expand Down
Loading

0 comments on commit 7d6604f

Please sign in to comment.