Merge pull request #5313 from trumant/k8s-backend-skipTLSVerify-configurable
Configuration of the kubernetes-backend should be able to toggle TLS verification
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-kubernetes-backend': patch
|
||||
---
|
||||
|
||||
Kubernetes client TLS verification is now configurable and defaults to true
|
||||
@@ -25,6 +25,7 @@ kubernetes:
|
||||
- url: http://127.0.0.1:9999
|
||||
name: minikube
|
||||
authProvider: 'serviceAccount'
|
||||
skipTLSVerify: false
|
||||
serviceAccountToken: ${K8S_MINIKUBE_TOKEN}
|
||||
- url: http://127.0.0.2:9999
|
||||
name: aws-cluster-1
|
||||
@@ -78,6 +79,11 @@ cluster. Valid values are:
|
||||
| `serviceAccount` | This will use a Kubernetes [service account](https://kubernetes.io/docs/reference/access-authn-authz/service-accounts-admin/) to access the Kubernetes API. When this is used the `serviceAccountToken` field should also be set. |
|
||||
| `google` | This will use a user's Google auth token from the [Google auth plugin](https://backstage.io/docs/auth/) to access the Kubernetes API. |
|
||||
|
||||
##### `clusters.\*.skipTLSVerify`
|
||||
|
||||
This determines whether or not the Kubernetes client verifies the TLS
|
||||
certificate presented by the API server. Defaults to `false`.
|
||||
|
||||
##### `clusters.\*.serviceAccountToken` (optional)
|
||||
|
||||
The service account token to be used when using the `serviceAccount` auth
|
||||
|
||||
@@ -52,6 +52,7 @@ describe('ConfigClusterLocator', () => {
|
||||
serviceAccountToken: undefined,
|
||||
url: 'http://localhost:8080',
|
||||
authProvider: 'serviceAccount',
|
||||
skipTLSVerify: false,
|
||||
},
|
||||
]);
|
||||
});
|
||||
@@ -64,11 +65,13 @@ describe('ConfigClusterLocator', () => {
|
||||
serviceAccountToken: 'token',
|
||||
url: 'http://localhost:8080',
|
||||
authProvider: 'serviceAccount',
|
||||
skipTLSVerify: false,
|
||||
},
|
||||
{
|
||||
name: 'cluster2',
|
||||
url: 'http://localhost:8081',
|
||||
authProvider: 'google',
|
||||
skipTLSVerify: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -83,12 +86,14 @@ describe('ConfigClusterLocator', () => {
|
||||
serviceAccountToken: 'token',
|
||||
url: 'http://localhost:8080',
|
||||
authProvider: 'serviceAccount',
|
||||
skipTLSVerify: false,
|
||||
},
|
||||
{
|
||||
name: 'cluster2',
|
||||
serviceAccountToken: undefined,
|
||||
url: 'http://localhost:8081',
|
||||
authProvider: 'google',
|
||||
skipTLSVerify: true,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -33,6 +33,7 @@ export class ConfigClusterLocator implements KubernetesClustersSupplier {
|
||||
name: c.getString('name'),
|
||||
url: c.getString('url'),
|
||||
serviceAccountToken: c.getOptionalString('serviceAccountToken'),
|
||||
skipTLSVerify: c.getOptionalBoolean('skipTLSVerify') ?? false,
|
||||
authProvider: c.getString('authProvider'),
|
||||
};
|
||||
}),
|
||||
|
||||
@@ -53,12 +53,14 @@ describe('getCombinedClusterDetails', () => {
|
||||
serviceAccountToken: 'token',
|
||||
url: 'http://localhost:8080',
|
||||
authProvider: 'serviceAccount',
|
||||
skipTLSVerify: false,
|
||||
},
|
||||
{
|
||||
name: 'cluster2',
|
||||
serviceAccountToken: undefined,
|
||||
url: 'http://localhost:8081',
|
||||
authProvider: 'google',
|
||||
skipTLSVerify: false,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -34,6 +34,7 @@ describe('KubernetesClientProvider', () => {
|
||||
url: 'http://localhost:9999',
|
||||
serviceAccountToken: 'TOKEN',
|
||||
authProvider: 'serviceAccount',
|
||||
skipTLSVerify: false,
|
||||
});
|
||||
|
||||
expect(result.basePath).toBe('http://localhost:9999');
|
||||
@@ -41,6 +42,7 @@ describe('KubernetesClientProvider', () => {
|
||||
const auth = (result as any).authentications.default;
|
||||
expect(auth.users[0].token).toBe('TOKEN');
|
||||
expect(auth.clusters[0].name).toBe('cluster-name');
|
||||
expect(auth.clusters[0].skipTLSVerify).toBe(false);
|
||||
|
||||
expect(mockGetKubeConfig.mock.calls.length).toBe(1);
|
||||
});
|
||||
@@ -57,6 +59,7 @@ describe('KubernetesClientProvider', () => {
|
||||
url: 'http://localhost:9999',
|
||||
serviceAccountToken: 'TOKEN',
|
||||
authProvider: 'serviceAccount',
|
||||
skipTLSVerify: false,
|
||||
});
|
||||
|
||||
expect(result.basePath).toBe('http://localhost:9999');
|
||||
|
||||
@@ -30,8 +30,7 @@ export class KubernetesClientProvider {
|
||||
const cluster = {
|
||||
name: clusterDetails.name,
|
||||
server: clusterDetails.url,
|
||||
// TODO configure this
|
||||
skipTLSVerify: true,
|
||||
skipTLSVerify: clusterDetails.skipTLSVerify,
|
||||
};
|
||||
|
||||
// TODO configure
|
||||
|
||||
@@ -30,6 +30,7 @@ export interface ClusterDetails {
|
||||
url: string;
|
||||
authProvider: string;
|
||||
serviceAccountToken?: string | undefined;
|
||||
skipTLSVerify?: boolean;
|
||||
}
|
||||
|
||||
export interface KubernetesRequestBody {
|
||||
|
||||
Reference in New Issue
Block a user