Skip to content

Commit 866184c

Browse files
authored
allow end users to configure additional trusted certificate authorities (#4884)
* begin passing through additional CAs * refer to existing configmaps * add PrivateCACertNamespace function * specify private CAs configmap via CLI * f * begin integration test for flag * set env var * create ns * use the right namespace * add private-ca-configmap to generate-manifests * check for cert file and env vars in deployment * add basic generate-manifests test * manifest namespace * fix cat * remove cat * rename TrustedCAsConfigmap to PrivateCAsConfigmap
1 parent a63917b commit 866184c

File tree

7 files changed

+280
-84
lines changed

7 files changed

+280
-84
lines changed

.github/workflows/build-test.yaml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4209,6 +4209,120 @@ jobs:
42094209
api-token: ${{ secrets.C11Y_MATRIX_TOKEN }}
42104210
cluster-id: ${{ steps.create-cluster.outputs.cluster-id }}
42114211

4212+
validate-custom-cas:
4213+
runs-on: ubuntu-20.04
4214+
needs: [ enable-tests, can-run-ci, build-kots, build-kotsadm, build-kurl-proxy, build-migrations, push-minio, push-rqlite ]
4215+
strategy:
4216+
fail-fast: false
4217+
matrix:
4218+
cluster: [
4219+
{distribution: kind, version: v1.28.0}
4220+
]
4221+
env:
4222+
APP_SLUG: get-set-config
4223+
steps:
4224+
- name: Checkout
4225+
uses: actions/checkout@v4
4226+
4227+
- name: Create Cluster
4228+
id: create-cluster
4229+
uses: replicatedhq/replicated-actions/create-cluster@v1
4230+
with:
4231+
api-token: ${{ secrets.C11Y_MATRIX_TOKEN }}
4232+
kubernetes-distribution: ${{ matrix.cluster.distribution }}
4233+
kubernetes-version: ${{ matrix.cluster.version }}
4234+
cluster-name: automated-kots-${{ github.run_id }}-${{ matrix.cluster.distribution }}-${{ matrix.cluster.version }}
4235+
timeout-minutes: '120'
4236+
ttl: 2h
4237+
export-kubeconfig: true
4238+
4239+
- name: download kots binary
4240+
uses: actions/download-artifact@v4
4241+
with:
4242+
name: kots
4243+
path: bin/
4244+
4245+
- run: chmod +x bin/kots
4246+
4247+
- name: create namespace and dockerhub secret
4248+
run: |
4249+
kubectl create ns "$APP_SLUG"
4250+
kubectl create secret docker-registry kotsadm-dockerhub --docker-server index.docker.io --docker-username "${{ secrets.E2E_DOCKERHUB_USERNAME }}" --docker-password "${{ secrets.E2E_DOCKERHUB_PASSWORD }}" --namespace "$APP_SLUG"
4251+
4252+
- name: install yq
4253+
run: |
4254+
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
4255+
sudo chmod +x /usr/bin/yq
4256+
4257+
- name: run the test
4258+
run: |
4259+
set -e
4260+
echo ${{ secrets.GET_SET_CONFIG_LICENSE }} | base64 -d > license.yaml
4261+
4262+
echo "test value" > ./ca.crt
4263+
kubectl create configmap -n "$APP_SLUG" custom-cas --from-file=ca.crt=./ca.crt
4264+
4265+
./bin/kots \
4266+
install "$APP_SLUG/automated" \
4267+
--license-file license.yaml \
4268+
--no-port-forward \
4269+
--namespace "$APP_SLUG" \
4270+
--shared-password password \
4271+
--kotsadm-registry ttl.sh \
4272+
--kotsadm-namespace automated-${{ github.run_id }} \
4273+
--private-ca-configmap custom-cas \
4274+
--kotsadm-tag 24h
4275+
4276+
echo "exec into the deployment and check for the file and its contents"
4277+
if ! kubectl exec -n "$APP_SLUG" deployment/kotsadm -- cat /certs/ca.crt | grep "test value"; then
4278+
echo "expected /certs/ca.crt to contain 'test value'"
4279+
kubectl exec -n "$APP_SLUG" deployment/kotsadm -- cat /certs/ca.crt
4280+
exit 1
4281+
fi
4282+
4283+
echo "check that the deployment has an environment variable pointing to the file"
4284+
if ! kubectl exec -n "$APP_SLUG" deployment/kotsadm -- env | grep "SSL_CERT_DIR" | grep "/certs"; then
4285+
echo "expected env output to contain SSL_CERT_DIR=/certs"
4286+
kubectl exec -n "$APP_SLUG" deployment/kotsadm -- env
4287+
exit 1
4288+
fi
4289+
4290+
echo "check that the deployment has an environment variable with the configmap name"
4291+
if ! kubectl exec -n "$APP_SLUG" deployment/kotsadm -- env | grep "SSL_CERT_CONFIGMAP" | grep "custom-cas"; then
4292+
echo "expected env output to contain SSL_CERT_CONFIGMAP=custom-cas"
4293+
kubectl exec -n "$APP_SLUG" deployment/kotsadm -- env
4294+
exit 1
4295+
fi
4296+
4297+
./bin/kots admin-console generate-manifests -n "$APP_SLUG" --shared-password password --private-ca-configmap generated-custom-cas
4298+
ls ./admin-console
4299+
if ! grep SSL_CERT_CONFIGMAP < ./admin-console/kotsadm-deployment.yaml; then
4300+
echo "expected generated kotsadm-deployment.yaml to contain SSL_CERT_CONFIGMAP"
4301+
cat ./admin-console/kotsadm-deployment.yaml
4302+
exit 1
4303+
fi
4304+
if ! grep generated-custom-cas < ./admin-console/kotsadm-deployment.yaml; then
4305+
echo "expected generated kotsadm-deployment.yaml to contain generated-custom-cas"
4306+
cat ./admin-console/kotsadm-deployment.yaml
4307+
exit 1
4308+
fi
4309+
4310+
- name: Generate support bundle on failure
4311+
if: failure()
4312+
uses: ./.github/actions/generate-support-bundle
4313+
with:
4314+
kots-namespace: "$APP_SLUG"
4315+
artifact-name: ${{ github.job }}-${{ matrix.cluster.distribution }}-${{ matrix.cluster.version }}-support-bundle
4316+
4317+
- name: Remove Cluster
4318+
id: remove-cluster
4319+
uses: replicatedhq/replicated-actions/remove-cluster@v1
4320+
if: ${{ always() && steps.create-cluster.outputs.cluster-id != '' }}
4321+
continue-on-error: true
4322+
with:
4323+
api-token: ${{ secrets.C11Y_MATRIX_TOKEN }}
4324+
cluster-id: ${{ steps.create-cluster.outputs.cluster-id }}
4325+
42124326

42134327
validate-pr-tests:
42144328
runs-on: ubuntu-20.04
@@ -4254,6 +4368,7 @@ jobs:
42544368
- validate-replicated-sdk
42554369
- validate-strict-preflight-checks
42564370
- validate-get-set-config
4371+
- validate-custom-cas
42574372
# cli-only tests
42584373
- validate-kots-push-images-anonymous
42594374
steps:

cmd/kots/cli/admin-console-generate-manifests.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ func AdminGenerateManifestsCmd() *cobra.Command {
7373
IsOpenShift: isOpenShift,
7474
IsGKEAutopilot: isGKEAutopilot,
7575
RegistryConfig: registryConfig,
76+
PrivateCAsConfigmap: v.GetString("private-ca-configmap"),
7677
}
7778
adminConsoleFiles, err := upstream.GenerateAdminConsoleFiles(renderDir, options)
7879
if err != nil {
@@ -104,6 +105,7 @@ func AdminGenerateManifestsCmd() *cobra.Command {
104105
cmd.Flags().String("https-proxy", "", "sets HTTPS_PROXY environment variable in all KOTS Admin Console components")
105106
cmd.Flags().String("no-proxy", "", "sets NO_PROXY environment variable in all KOTS Admin Console components")
106107
cmd.Flags().String("shared-password", "", "shared password to use when deploying the admin console")
108+
cmd.Flags().String("private-ca-configmap", "", "the name of a configmap containing private CAs to add to the kotsadm deployment")
107109
cmd.Flags().Bool("with-minio", true, "set to true to include a local minio instance to be used for storage")
108110
cmd.Flags().Bool("minimal-rbac", false, "set to true to use the namespaced role and bindings instead of cluster-level permissions")
109111
cmd.Flags().StringSlice("additional-namespaces", []string{}, "Comma separate list to specify additional namespace(s) managed by KOTS outside where it is to be deployed. Ignored without with '--minimal-rbac=true'")

cmd/kots/cli/install.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ func InstallCmd() *cobra.Command {
308308
RequestedChannelSlug: preferredChannelSlug,
309309
AdditionalLabels: additionalLabels,
310310
AdditionalAnnotations: additionalAnnotations,
311+
PrivateCAsConfigmap: v.GetString("private-ca-configmap"),
311312

312313
RegistryConfig: *registryConfig,
313314

@@ -551,6 +552,7 @@ func InstallCmd() *cobra.Command {
551552
cmd.Flags().Bool("exclude-admin-console", false, "set to true to exclude the admin console and only install the application")
552553
cmd.Flags().StringArray("additional-annotations", []string{}, "additional annotations to add to kotsadm pods")
553554
cmd.Flags().StringArray("additional-labels", []string{}, "additional labels to add to kotsadm pods")
555+
cmd.Flags().String("private-ca-configmap", "", "the name of a configmap containing private CAs to add to the kotsadm deployment")
554556

555557
registryFlags(cmd.Flags())
556558

0 commit comments

Comments
 (0)