-
Notifications
You must be signed in to change notification settings - Fork 10
feat: automated boostrapping of coco for a single cluster #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| --- | ||
| - name: Retrieve Credentials for AAP on OpenShift | ||
| become: false | ||
| connection: local | ||
| hosts: localhost | ||
| gather_facts: false | ||
| vars: | ||
| kubeconfig: "{{ lookup('env', 'KUBECONFIG') }}" | ||
| tasks: | ||
| - name: Get Azure credentials | ||
| kubernetes.core.k8s_info: | ||
| kind: Secret | ||
| namespace: openshift-cloud-controller-manager | ||
| name: azure-cloud-credentials | ||
| register: azure_credentials | ||
| retries: 20 | ||
| delay: 5 | ||
| - name: List DNS zones | ||
| azure.azcollection.azure_rm_dnszone_info: | ||
| #resource_group: "{{ azure_credentials['data']['re'] }}" # don't pass if | ||
| auth_source: "auto" | ||
| subscription_id: "{{ azure_credentials.resources[0]['data']['azure_subscription_id'] | b64decode }}" | ||
| client_id: "{{ azure_credentials.resources[0]['data']['azure_client_id'] | b64decode }}" | ||
| secret: "{{ azure_credentials.resources[0]['data']['azure_client_secret'] | b64decode }}" | ||
| tenant: "{{ azure_credentials.resources[0]['data']['azure_tenant_id'] | b64decode }}" | ||
| register: dns_zones | ||
| # FIXME: This assumes only one dns zone is present. we should be matching against available dns zones. | ||
| - name: Split the Path | ||
| set_fact: | ||
| path_parts: "{{ dns_zones.ansible_info.azure_dnszones[0].id.split('/') }}" | ||
| - name: Find the Resource Group Name | ||
| set_fact: | ||
| resource_group: "{{ path_parts[4] }}" | ||
| - name: Get hosted zone | ||
| set_fact: | ||
| hosted_zone: "{{ dns_zones.ansible_info.azure_dnszones[0].name }}" | ||
| - name: "Set k8s cm" | ||
| kubernetes.core.k8s: | ||
| api_version: v1 | ||
| kind: ConfigMap | ||
| resource_definition: | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: dnsinfo | ||
| namespace: imperative | ||
| data: | ||
| resource_group: "{{ resource_group }}" | ||
| hosted_zone: "{{ hosted_zone }}" | ||
| state: present |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| - name: Retrieve Credentials for AAP on OpenShift | ||
| become: false | ||
| connection: local | ||
| hosts: localhost | ||
| gather_facts: false | ||
| tasks: | ||
| - name: Install required collection | ||
| ansible.builtin.command: | ||
| cmd: ansible-galaxy collection install azure.azcollection | ||
| - name: Install a Python package | ||
| ansible.builtin.command: | ||
| cmd: pip install --user -r ~/.ansible/collections/ansible_collections/azure/azcollection/requirements.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| {{ if .Values.letsencrypt.enabled }} | ||
| {{ if and (eq .Values.global.clusterPlatform "Azure") .Values.letsencrypt.cloudProviderDNS }} | ||
| --- | ||
| ## USE ACM policies to enforce the creation of a lets-encrypt cert | ||
| apiVersion: policy.open-cluster-management.io/v1 | ||
| kind: Policy | ||
| metadata: | ||
| name: azure-secret-policy | ||
| spec: | ||
| remediationAction: enforce | ||
| disabled: false | ||
| policy-templates: | ||
| - objectDefinition: | ||
| apiVersion: policy.open-cluster-management.io/v1 | ||
| kind: ConfigurationPolicy | ||
| metadata: | ||
| name: azure-client-creds | ||
| spec: | ||
| remediationAction: enforce | ||
| severity: medium | ||
| object-templates: | ||
| - complianceType: mustonlyhave | ||
| objectDefinition: | ||
| apiVersion: v1 | ||
| type: Opaque | ||
| kind: Secret | ||
| metadata: | ||
| name: azuredns-config | ||
| namespace: cert-manager | ||
| data: | ||
| client-secret: '{{ `{{ fromSecret "openshift-cloud-controller-manager" "azure-cloud-credentials" "azure_client_secret" }}` }}' | ||
| --- | ||
| apiVersion: policy.open-cluster-management.io/v1 | ||
| kind: PlacementBinding | ||
| metadata: | ||
| name: azure-secret-placement-binding | ||
| annotations: | ||
| argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true | ||
| placementRef: | ||
| name: azure-managed-clusters-placement-rule | ||
| kind: PlacementRule | ||
| apiGroup: apps.open-cluster-management.io | ||
| subjects: | ||
| - name: azure-secret-policy | ||
| kind: Policy | ||
| apiGroup: policy.open-cluster-management.io | ||
| ------ | ||
| apiVersion: apps.open-cluster-management.io/v1 | ||
| kind: PlacementRule | ||
| metadata: | ||
| name: azure-managed-clusters-placement-rule | ||
| spec: | ||
| clusterConditions: | ||
| - status: 'True' | ||
| type: ManagedClusterConditionAvailable | ||
| clusterSelector: | ||
| matchLabels: | ||
| cloud: Azure | ||
|
|
||
| --- | ||
| {{- end }} | ||
| {{- end }} |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| {{ if .Values.letsencrypt.enabled }} | ||
| {{ if and (eq .Values.global.clusterPlatform "Azure") .Values.letsencrypt.cloudProviderDNS }} | ||
| --- | ||
| apiVersion: policy.open-cluster-management.io/v1 | ||
| kind: Policy | ||
| metadata: | ||
| name: azure-cluster-issuer-policy | ||
| spec: | ||
| remediationAction: enforce | ||
| disabled: false | ||
| policy-templates: | ||
| - objectDefinition: | ||
| apiVersion: policy.open-cluster-management.io/v1 | ||
| kind: ConfigurationPolicy | ||
| metadata: | ||
| name: azure-cluster-issuer | ||
| spec: | ||
| remediationAction: enforce | ||
| severity: medium | ||
| object-templates: | ||
| - complianceType: mustonlyhave | ||
| objectDefinition: | ||
| apiVersion: cert-manager.io/v1 | ||
| kind: ClusterIssuer | ||
| metadata: | ||
| name: validated-patterns-issuer | ||
| spec: | ||
| acme: | ||
| server: {{ .Values.letsencrypt.server }} | ||
| email: {{ .Values.letsencrypt.email }} | ||
| privateKeySecretRef: | ||
| name: validated-patterns-issuer-account-key | ||
| solvers: | ||
| - dns01: | ||
| azureDNS: | ||
| # This info is also available in CM's however it's easier to get from the secret | ||
| clientID: '{{ `{{ fromSecret "openshift-cloud-controller-manager" "azure-cloud-credentials" "azure_client_id" | base64dec }}` }}' | ||
| clientSecretSecretRef: | ||
| # The following is the secret we created in Kubernetes. Issuer will use this to present challenge to Azure DNS. | ||
| name: azuredns-config | ||
| key: client-secret | ||
| subscriptionID: '{{ `{{ (fromJson (fromConfigMap "openshift-cloud-controller-manager" "cloud-conf" "cloud.conf" | toLiteral)).subscriptionId }}` }}' | ||
| tenantID: '{{ `{{ (fromJson (fromConfigMap "openshift-cloud-controller-manager" "cloud-conf" "cloud.conf" | toLiteral)).tenantId }}` }}' | ||
| resourceGroupName: '{{ `{{ fromConfigMap "imperative" "dnsinfo" "resource_group" }}` }}' | ||
| hostedZoneName: '{{ `{{ fromConfigMap "imperative" "dnsinfo" "hosted_zone" }}` }}' | ||
| # Azure Cloud Environment, default to AzurePublicCloud | ||
| environment: AzurePublicCloud | ||
| --- | ||
| apiVersion: policy.open-cluster-management.io/v1 | ||
| kind: PlacementBinding | ||
| metadata: | ||
| name: azure-issuer-placement-binding | ||
| annotations: | ||
| argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true | ||
| placementRef: | ||
| name: azure-issuer-placement-rule | ||
| kind: PlacementRule | ||
| apiGroup: apps.open-cluster-management.io | ||
| subjects: | ||
| - name: azure-cluster-issuer-policy | ||
| kind: Policy | ||
| apiGroup: policy.open-cluster-management.io | ||
| --- | ||
| apiVersion: apps.open-cluster-management.io/v1 | ||
| kind: PlacementRule | ||
| metadata: | ||
| name: azure-issuer-placement-rule | ||
| spec: | ||
| clusterConditions: | ||
| - status: 'True' | ||
| type: ManagedClusterConditionAvailable | ||
| clusterSelector: | ||
| matchLabels: | ||
| cloud: Azure | ||
| --- | ||
| {{- end }} | ||
| {{- end }} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.