|
| 1 | +apiVersion: apiextensions.crossplane.io/v1 |
| 2 | +kind: Composition |
| 3 | +metadata: |
| 4 | + name: k3sclusters.deployments.equinix.com |
| 5 | +spec: |
| 6 | + writeConnectionSecretsToNamespace: crossplane-system |
| 7 | + compositeTypeRef: |
| 8 | + apiVersion: deployments.equinix.com/v1alpha1 |
| 9 | + kind: K3sCluster |
| 10 | + resources: |
| 11 | + - name: k3s-project |
| 12 | + base: |
| 13 | + apiVersion: metal.equinix.jet.crossplane.io/v1alpha1 |
| 14 | + kind: Project |
| 15 | + patches: |
| 16 | + - type: FromCompositeFieldPath |
| 17 | + fromFieldPath: metadata.name |
| 18 | + toFieldPath: spec.forProvider.name |
| 19 | + - name: k3s-server |
| 20 | + base: |
| 21 | + apiVersion: metal.equinix.jet.crossplane.io/v1alpha1 |
| 22 | + kind: Device |
| 23 | + metadata: |
| 24 | + labels: |
| 25 | + k3s-server: 'true' |
| 26 | + spec: |
| 27 | + forProvider: |
| 28 | + hostname: k3s-server |
| 29 | + plan: c3.small.x86 |
| 30 | + operatingSystem: ubuntu_20_04 |
| 31 | + billingCycle: hourly |
| 32 | + locked: false |
| 33 | + networkType: hybrid |
| 34 | + tags: |
| 35 | + - crossplane |
| 36 | + projectIdSelector: |
| 37 | + matchControllerRef: true |
| 38 | + writeConnectionSecretToRef: |
| 39 | + name: server |
| 40 | + namespace: crossplane-system |
| 41 | + reclaimPolicy: Delete |
| 42 | + patches: |
| 43 | + - type: ToCompositeFieldPath |
| 44 | + fromFieldPath: status.atProvider.accessPublicIpv4 |
| 45 | + toFieldPath: status.serverIP |
| 46 | + - type: FromCompositeFieldPath |
| 47 | + fromFieldPath: spec.metro |
| 48 | + toFieldPath: spec.forProvider.metro |
| 49 | + - type: CombineFromComposite |
| 50 | + toFieldPath: spec.forProvider.userdata |
| 51 | + combine: |
| 52 | + variables: |
| 53 | + - fromFieldPath: spec.k3stoken |
| 54 | + strategy: string |
| 55 | + string: |
| 56 | + fmt: | |
| 57 | + #cloud-config |
| 58 | + write_files: |
| 59 | + #- permissions: '0660' |
| 60 | + # path: /etc/rancher/k3s/config.yaml |
| 61 | + # content: | |
| 62 | + # # k3s config |
| 63 | + runcmd: |
| 64 | + - sudo apt update |
| 65 | + - sudo apt upgrade -y |
| 66 | + - curl -sfL https://get.k3s.io | \ |
| 67 | + INSTALL_K3S_EXEC="server" \ |
| 68 | + K3S_TOKEN="%s" sh - |
| 69 | + - name: k3s-agent |
| 70 | + base: |
| 71 | + apiVersion: metal.equinix.jet.crossplane.io/v1alpha1 |
| 72 | + kind: Device |
| 73 | + metadata: |
| 74 | + labels: |
| 75 | + k3s-agent: 'true' |
| 76 | + spec: |
| 77 | + forProvider: |
| 78 | + hostname: k3s-agent |
| 79 | + plan: c3.small.x86 |
| 80 | + operatingSystem: ubuntu_20_04 |
| 81 | + billingCycle: hourly |
| 82 | + locked: false |
| 83 | + networkType: hybrid |
| 84 | + tags: |
| 85 | + - crossplane |
| 86 | + projectIdSelector: |
| 87 | + matchControllerRef: true |
| 88 | + writeConnectionSecretToRef: |
| 89 | + name: crossplane-conformance |
| 90 | + namespace: crossplane-system |
| 91 | + reclaimPolicy: Delete |
| 92 | + patches: |
| 93 | + # TODO we reuse metro patches. create a 'patchtype' |
| 94 | + - type: FromCompositeFieldPath |
| 95 | + fromFieldPath: spec.metro |
| 96 | + toFieldPath: spec.forProvider.metro |
| 97 | + - type: CombineFromComposite |
| 98 | + toFieldPath: spec.forProvider.userdata |
| 99 | + policy: |
| 100 | + fromFieldPath: Required |
| 101 | + combine: |
| 102 | + variables: |
| 103 | + - fromFieldPath: spec.k3stoken |
| 104 | + - fromFieldPath: status.serverIP |
| 105 | + strategy: string |
| 106 | + string: |
| 107 | + fmt: | |
| 108 | + #cloud-config |
| 109 | + write_files: |
| 110 | + #- permissions: '0660' |
| 111 | + # path: /etc/rancher/k3s/config.yaml |
| 112 | + # content: | |
| 113 | + # # k3s config |
| 114 | + runcmd: |
| 115 | + - sudo apt update |
| 116 | + - sudo apt upgrade -y |
| 117 | + - curl -sfL https://get.k3s.io | \ |
| 118 | + K3S_TOKEN="%s" \ |
| 119 | + K3S_URL=https://%s:6443 sh - |
0 commit comments