Skip to content

Commit e7ef96a

Browse files
fix: improve registry documentation (#1664) (#1679)
Co-authored-by: Harrison <harrisonaffel@gmail.com>
1 parent 2061872 commit e7ef96a

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

docs/resources/cluster_v2.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ resource "rancher2_cluster_v2" "foo" {
523523

524524
### Create a cluster that uses a cluster-level authenticated `system-default-registry`
525525

526-
The `<auth-config-secret-name>` represents a generic Kubernetes secret that contains two keys with base64 encoded values: the `username` and `password` for the specified custom registry. If the `system-default-registry` is not authenticated, no secret is required and the section within the `rke_config` can be omitted if not otherwise needed.
526+
The `<auth-config-secret-name>` represents a generic Kubernetes secret that contains two keys with base64 encoded values: the `username` and `password` for the specified custom registry. If the `system-default-registry` is not authenticated, no secret is required and the section within the `rke_config` can be omitted if not otherwise needed. While the below example shows how to create a registry secret, storing plain text credentials in terraform files is never a good idea. Significant care should be taken to ensure that the username and password values are not committed or otherwise leaked.
527527

528528
Many registries may be specified in the `rke_config`s `registries` section, however, the `system-default-registry` from which core system images are pulled is always denoted via the `system-default-registry` key of the `machine_selector_config` or the `machine_global_config`. For more information on private registries, please refer to [the Rancher documentation](https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/authentication-permissions-and-global-configuration/global-default-private-registry#setting-a-private-registry-with-credentials-when-deploying-a-cluster).
529529

@@ -533,14 +533,13 @@ resource "rancher2_cluster_v2" "foo_cluster_v2" {
533533
kubernetes_version = "rke2/k3s-version"
534534
rke_config {
535535
machine_selector_config {
536-
config = {
537-
system-default-registry: "custom-registry-hostname"
538-
}
536+
# config is a string which represents a yaml object
537+
config = "system-default-registry: registry_domain_name"
539538
}
540539
registries {
541540
configs {
542-
hostname = "custom-registry-hostname"
543-
auth_config_secret_name = "<auth-config-secret-name>"
541+
hostname = "registry_domain_name"
542+
auth_config_secret_name = var.registry_secret_name
544543
insecure = "<tls-insecure-bool>"
545544
tls_secret_name = ""
546545
ca_bundle = ""
@@ -552,6 +551,18 @@ resource "rancher2_cluster_v2" "foo_cluster_v2" {
552551
}
553552
}
554553
}
554+
555+
# create registry auth secret
556+
resource "rancher2_secret_v2" "my_registry" {
557+
cluster_id = "local"
558+
name = var.registry_secret_name
559+
namespace = "fleet-default"
560+
type = "kubernetes.io/basic-auth"
561+
data = {
562+
username = var.registry_username
563+
password = var.registry_password
564+
}
565+
}
555566
```
556567

557568
### Creating Rancher V2 Cluster with Machine Selector Files

0 commit comments

Comments
 (0)