|
| 1 | +<!-- SPDX-License-Identifier: MIT --> |
| 2 | + |
| 3 | +# compatibility |
| 4 | + |
| 5 | +<!-- toc --> |
| 6 | +- [update to operator 0.4.x](#update-to-operator-04x) |
| 7 | + - [1. update <code>garm</code> to version <code>>=0.1.5</code>](#1-update-garm-to-version-015) |
| 8 | + - [2. update <code>garm-operator</code> to version <code>0.4.x</code>](#2-update-garm-operator-to-version-04x) |
| 9 | + - [3. create new <code>CustomResources</code>](#3-create-new-customresources) |
| 10 | +<!-- /toc --> |
| 11 | + |
| 12 | +## update to operator 0.4.x |
| 13 | + |
| 14 | +> [!WARNING] |
| 15 | +> `garm-operator` in version `0.4.x` is not compatible with `garm` in version `0.1.4`. |
| 16 | +> If you connect `garm-operator` in version `0.4.x` to `garm` in version `0.1.4`, |
| 17 | +> the operator will stop working as we check the `garm` version in the operator. |
| 18 | +
|
| 19 | +### 1. update `garm` to version `>=0.1.5` |
| 20 | + |
| 21 | +`garm-operator` in version `0.3.x` is compatible with `garm` in version `0.1.5`, if the `garm` server got updated from `0.1.4` to `0.1.5`. |
| 22 | +This is because `garm` is doing some migration steps by moving parts of the configuration from the `garm` server to the `garm` API. |
| 23 | +These newly introduced API endpoints are not by `garm-operator` in version `0.3.x`. |
| 24 | + |
| 25 | +Therefore it's possible to still work with the existing `CustomResources`. |
| 26 | + |
| 27 | +### 2. update `garm-operator` to version `0.4.x` |
| 28 | + |
| 29 | +Once `garm` got updated to version `0.1.5`, you can update the `garm-operator` to version `0.4.x`. |
| 30 | + |
| 31 | +### 3. create new `CustomResources` |
| 32 | + |
| 33 | +As `garm` moved some configuration parts to the API, you have to create a few new `CustomResources`. |
| 34 | +Without these new `CustomResources`, `garm-operator` is not able to reconcile `Enterprises`, `Organizations` and `Repository` objects. |
| 35 | + |
| 36 | +#### 3.1 create a `GarmServerConfig` object |
| 37 | + |
| 38 | +It's now possible to define the `callbackUrl`, `metadataUrl` and `webhookUrl` via a `GarmServerConfig` object. Therefore it's not needed anymore to restart the `garm` server to apply these changes. |
| 39 | + |
| 40 | +```yaml |
| 41 | +apiVersion: garm-operator.mercedes-benz.com/v1beta1 |
| 42 | +kind: GarmServerConfig |
| 43 | +metadata: |
| 44 | + name: garm-server-config |
| 45 | + namespace: garm-operator-system |
| 46 | +spec: |
| 47 | + callbackUrl: http://<fqdn-to-your-garm-server-instance>/api/v1/callbacks |
| 48 | + metadataUrl: http://<fqdn-to-your-garm-server-instance>/api/v1/metadata |
| 49 | + webhookUrl: http://<fqdn-to-your-garm-server-instance>/api/v1/webhook |
| 50 | +``` |
| 51 | +
|
| 52 | +By running `kubectl get garmserverconfig` you should see the newly created `GarmServerConfig` object. |
| 53 | + |
| 54 | +```bash |
| 55 | +NAME ID VERSION AGE |
| 56 | +garm-server-config dd2524b9-0789-499d-ba7d-3dba65cf9d3f v0.1.5 16h |
| 57 | +``` |
| 58 | + |
| 59 | +More information about the defined Urls can be found [in the garm documentation](https://github.com/cloudbase/garm/blob/main/doc/using_garm.md#controller-operations). |
| 60 | + |
| 61 | +#### 3.2 create `GitHubEndpoint` objects |
| 62 | + |
| 63 | +The `GitHubEndpoint` objects are used to define the connection to the GitHub API. It's possible to define multiple `GitHubEndpoint` objects to connect to different GitHub instances. |
| 64 | + |
| 65 | +```yaml |
| 66 | +apiVersion: garm-operator.mercedes-benz.com/v1beta1 |
| 67 | +kind: GitHubEndpoint |
| 68 | +metadata: |
| 69 | + name: github-enterprise |
| 70 | + namespace: garm-operator-system |
| 71 | +spec: |
| 72 | + description: "github" |
| 73 | + apiBaseUrl: "https://github.com" |
| 74 | + uploadBaseUrl: "https://uploads.github.com" |
| 75 | + baseUrl: "https://api.github.com/" |
| 76 | +``` |
| 77 | + |
| 78 | +By running `kubectl get githubendpoint` you should see the newly created `GitHubEndpoint` object. |
| 79 | + |
| 80 | +```bash |
| 81 | +NAME URL READY AGE |
| 82 | +github https://github.com True 3m2s |
| 83 | +``` |
| 84 | + |
| 85 | +More information about the github endpoints can be found [in the garm documentation](https://github.com/cloudbase/garm/blob/main/doc/using_garm.md#github-endpoints) |
| 86 | + |
| 87 | +> [!NOTE] |
| 88 | +> `garm` already ships a default `Github` object. But as this object is immutable, and we do not wanted to reflect the object into the `garm-operator`, we decided to create a new `CustomResource` for this. See the [Reflection of the default GitHub endpoint ADR](docs/adrs/github_default_endpoint.md) for more information. |
| 89 | + |
| 90 | +#### 3.2 create `GitHubCredential` objects |
| 91 | + |
| 92 | +With the new `v1beta1` of `Enterprises`, `Organizations` or `Repositories`, the reference to the Github credential has changed. |
| 93 | +In the previous `v1alpha1`, the used credential was referenced by the `.spec.credentialsName` field, which then pointed to a credential object, specified in the `garm` server configuration. |
| 94 | + |
| 95 | +With the new `v1beta1`, the reference to the credential is done by the `.spec.credentialRef` field, which points to a `GitHubCredential` object. |
| 96 | + |
| 97 | +> [!NOTE] |
| 98 | +> As long as `GitHubCredential` is not applied in `v1beta1`, the `garm-operator` will quit reconciling `Enterprises`, `Organizations` or `Repositories`. |
| 99 | +> The current assumption is, that a `GitHubCredential`, which was set in `.spec.credentialsName` in `v1alpha1`, will be created as `GitHubCredential` in `v1beta1` with the same name. |
| 100 | +> If this is not the case, the `garm-operator` will not be able to reconcile the `Enterprises`, `Organizations` or `Repositories` objects. |
| 101 | +> This state can be seen in the `status.conditions` field of these objects. |
| 102 | +> |
| 103 | +> ```yaml |
| 104 | +> status: |
| 105 | +> conditions: |
| 106 | +> - lastTransitionTime: "2024-11-14T20:01:27Z" |
| 107 | +> message: GitHubCredential.garm-operator.mercedes-benz.com "github-pat" not found |
| 108 | +> reason: CredentialsRefFailed |
| 109 | +> status: "False" |
| 110 | +> type: Ready |
| 111 | +> - lastTransitionTime: "2024-11-14T20:01:27Z" |
| 112 | +> message: GitHubCredential.garm-operator.mercedes-benz.com "github-pat" not found |
| 113 | +> reason: CredentialsRefFailed |
| 114 | +> status: "False" |
| 115 | +> type: CredentialsRef |
| 116 | +> [...] |
| 117 | +> ``` |
| 118 | + |
| 119 | +Create the `GitHubCredential` object and a corresponding `Secret` object with the PAT token. |
| 120 | + |
| 121 | +```yaml |
| 122 | +apiVersion: garm-operator.mercedes-benz.com/v1beta1 |
| 123 | +kind: GitHubCredential |
| 124 | +metadata: |
| 125 | + name: github-pat |
| 126 | + namespace: garm-operator-system |
| 127 | +spec: |
| 128 | + description: PAT for github |
| 129 | + endpointRef: |
| 130 | + apiGroup: garm-operator.mercedes-benz.com |
| 131 | + kind: GitHubEndpoint |
| 132 | + name: github |
| 133 | + authType: pat |
| 134 | + secretRef: |
| 135 | + name: github-pat |
| 136 | + key: token |
| 137 | +--- |
| 138 | +apiVersion: v1 |
| 139 | +kind: Secret |
| 140 | +metadata: |
| 141 | + name: github-pat |
| 142 | + namespace: garm-operator-system |
| 143 | +data: |
| 144 | + token: <base64 encoded PAT> |
| 145 | +``` |
| 146 | + |
| 147 | +More information about the github credentials can be found [in the garm documentation](https://github.com/cloudbase/garm/blob/main/doc/using_garm.md#github-credentials) |
| 148 | + |
| 149 | +By running `kubectl get githubcredential` you should see the newly created `GitHubCredential` object. |
| 150 | + |
| 151 | +```bash |
| 152 | +NAME ID READY AUTHTYPE GITHUBENDPOINT AGE |
| 153 | +github-pat 1 True pat github 3m51s |
| 154 | +``` |
| 155 | + |
| 156 | +By running `kubectl get githubcredential -o wide` you see all the `Enterprise`, `Organization` or `Repository` objects which are using this `GitHubCredential`. |
| 157 | + |
| 158 | +```bash |
| 159 | +NAME ID READY ERROR AUTHTYPE GITHUBENDPOINT REPOSITORIES ORGANIZATIONS ENTERPRISES AGE |
| 160 | +github-pat 1 True pat github ["my-org"] 4m46s |
| 161 | +``` |
0 commit comments