Skip to content
This repository was archived by the owner on Nov 1, 2022. It is now read-only.

Commit a211ea3

Browse files
committed
Use ~/.kube/config to set default namespace
`kubectl` run from the pod uses the service account token, and inherits its default namespace from the service account. We want it to be the default default (named "default"), to mimic the behaviour of `kubectl` used from a terminal and thereby avoid some surprises. To reset the default namespace, we copy a Kubernetes config file with a context specifying the "default" namespace, to the place `kubectl` expects to find it, in the flux image.
1 parent 8ad9943 commit a211ea3

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ build/.%.done: docker/Dockerfile.%
4848
-f build/docker/$*/Dockerfile.$* ./build/docker/$*
4949
touch $@
5050

51-
build/.flux.done: build/fluxd build/kubectl docker/ssh_config
51+
build/.flux.done: build/fluxd build/kubectl docker/ssh_config docker/kubeconfig
5252
build/.helm-operator.done: build/helm-operator build/kubectl docker/ssh_config
5353

5454
build/fluxd: $(FLUXD_DEPS)

docker/Dockerfile.flux

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ RUN mkdir ~/.ssh && touch ~/.ssh/known_hosts && \
3131
COPY ./ssh_config /root/.ssh/config
3232
RUN chmod 600 /root/.ssh/config
3333

34+
COPY ./kubeconfig /root/.kube/config
3435
COPY ./kubectl /usr/local/bin/
3536
COPY ./fluxd /usr/local/bin/
3637

docker/kubeconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
clusters: []
3+
contexts:
4+
- context:
5+
cluster: ""
6+
namespace: default
7+
user: ""
8+
name: default
9+
current-context: default
10+
kind: Config
11+
preferences: {}
12+
users: []

0 commit comments

Comments
 (0)