|
1 | 1 | Operator to support failk8s
|
2 | 2 | ===========================
|
3 | 3 |
|
4 |
| -For now the operator only handles copying of secrets to namespaces. The |
5 |
| -ability to inject secrets into service accounts is still coming. |
| 4 | +This operator handles the copying of secrets between namespaces and the injection of image pull secrets into service accounts. |
6 | 5 |
|
7 |
| -Accepts a custom resource called ``SecretCopierConfig``. You can create |
8 |
| -more than one of this type of resource. |
| 6 | +Note that the operator does not delete secrets previously copied if the |
| 7 | +original secret is deleted, or if rules change such that it wouldn't have |
| 8 | +been created in the first place. The name of a secret is also not removed |
| 9 | +from the list of image pull secrets in a service account if the secret is |
| 10 | +removed or rules change meaning it would no longer have been added. |
| 11 | + |
| 12 | +To setup copying of secrets a custom resource exists called |
| 13 | +``SecretCopierConfig``. You can create more than one of this type of |
| 14 | +resource. |
9 | 15 |
|
10 | 16 | First example below will copy the secret from the specified namespace
|
11 | 17 | into all other namespaces. It will not attempt to copy the secret into
|
@@ -100,3 +106,111 @@ spec:
|
100 | 106 |
|
101 | 107 | The ``rules`` property is a list, so rules for more than one rule
|
102 | 108 | can technically be specified in the one custom resource.
|
| 109 | + |
| 110 | +To setup injection of secrets as an image pull secret against a service |
| 111 | +account a custom resource exists called ``SecretInjectorConfig``. You can |
| 112 | +create more than one of this type of resource. |
| 113 | + |
| 114 | +Note that nothing is done to validate the secret is of the correct type |
| 115 | +before it is added as an image pull secret in the service account. |
| 116 | + |
| 117 | +First example below will inject the named secrets when created in any |
| 118 | +namespace, into all service accounts in the same namespace as the secret. |
| 119 | +The names of the secrets is given by setting ``sourceSecrets.nameSelector``. |
| 120 | + |
| 121 | +``` |
| 122 | +apiVersion: failk8s.dev/v1alpha1 |
| 123 | +kind: SecretInjectorConfig |
| 124 | +metadata: |
| 125 | + name: registry-credentials |
| 126 | +spec: |
| 127 | + rules: |
| 128 | + - sourceSecrets: |
| 129 | + nameSelector: |
| 130 | + matchNames: |
| 131 | + - registry-credentials |
| 132 | +``` |
| 133 | + |
| 134 | +If you only want the secret injected into the ``default`` service account |
| 135 | +set ``serviceAccounts.nameSelector``. |
| 136 | + |
| 137 | +``` |
| 138 | +apiVersion: failk8s.dev/v1alpha1 |
| 139 | +kind: SecretInjectorConfig |
| 140 | +metadata: |
| 141 | + name: registry-credentials |
| 142 | +spec: |
| 143 | + rules: |
| 144 | + - sourceSecrets: |
| 145 | + nameSelector: |
| 146 | + matchNames: |
| 147 | + - registry-credentials |
| 148 | + serviceAccounts: |
| 149 | + nameSelector: |
| 150 | + matchNames: |
| 151 | + - default |
| 152 | +``` |
| 153 | + |
| 154 | +Labels can instead be used on both the source secret and service accounts |
| 155 | +using ``sourceSecrets.labelSelector`` and ``serviceAccounts.labelSelector``. |
| 156 | + |
| 157 | +``` |
| 158 | +apiVersion: failk8s.dev/v1alpha1 |
| 159 | +kind: SecretInjectorConfig |
| 160 | +metadata: |
| 161 | + name: registry-credentials |
| 162 | +spec: |
| 163 | + rules: |
| 164 | + - sourceSecrets: |
| 165 | + labelSelector: |
| 166 | + matchLabels: |
| 167 | + image-pull-secret: "yes" |
| 168 | + serviceAccounts: |
| 169 | + labelSelector: |
| 170 | + matchLabels: |
| 171 | + inject-image-pull-secrets: "yes" |
| 172 | +``` |
| 173 | + |
| 174 | +You can be selective about what namespaces injection is performed. This can |
| 175 | +be done specifying the names of the namespaces using |
| 176 | +``targetNamespaces.nameSelector``: |
| 177 | + |
| 178 | +``` |
| 179 | +apiVersion: failk8s.dev/v1alpha1 |
| 180 | +kind: SecretInjectorConfig |
| 181 | +metadata: |
| 182 | + name: registry-credentials |
| 183 | +spec: |
| 184 | + rules: |
| 185 | + - sourceSecrets: |
| 186 | + nameSelector: |
| 187 | + matchNames: |
| 188 | + - registry-credentials |
| 189 | + targetNamespaces: |
| 190 | + nameSelector: |
| 191 | + matchNames: |
| 192 | + - developer-1 |
| 193 | + - developer-2 |
| 194 | +``` |
| 195 | + |
| 196 | +or labels by setting ``targetNamespaces.labelSelector``: |
| 197 | + |
| 198 | +``` |
| 199 | +apiVersion: failk8s.dev/v1alpha1 |
| 200 | +kind: SecretInjectorConfig |
| 201 | +metadata: |
| 202 | + name: registry-credentials |
| 203 | +spec: |
| 204 | + rules: |
| 205 | + - sourceSecrets: |
| 206 | + nameSelector: |
| 207 | + matchNames: |
| 208 | + - registry-credentials |
| 209 | + targetNamespaces: |
| 210 | + labelSelector: |
| 211 | + matchLabels: |
| 212 | + developer-namespace: "yes" |
| 213 | +``` |
| 214 | + |
| 215 | +The ``rules`` property is a list, so rules for more than one rule |
| 216 | +can technically be specified in the one custom resource. |
0 commit comments