Browse Source

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.
Michael Bridgen 1 year ago
parent
commit
a211ea3d1e
3 changed files with 14 additions and 1 deletions
  1. 1
    1
      Makefile
  2. 1
    0
      docker/Dockerfile.flux
  3. 12
    0
      docker/kubeconfig

+ 1
- 1
Makefile View File

@@ -48,7 +48,7 @@ build/.%.done: docker/Dockerfile.%
48 48
 		-f build/docker/$*/Dockerfile.$* ./build/docker/$*
49 49
 	touch $@
50 50
 
51
-build/.flux.done: build/fluxd build/kubectl docker/ssh_config
51
+build/.flux.done: build/fluxd build/kubectl docker/ssh_config docker/kubeconfig
52 52
 build/.helm-operator.done: build/helm-operator build/kubectl docker/ssh_config
53 53
 
54 54
 build/fluxd: $(FLUXD_DEPS)

+ 1
- 0
docker/Dockerfile.flux View File

@@ -31,6 +31,7 @@ RUN mkdir ~/.ssh && touch ~/.ssh/known_hosts && \
31 31
 COPY ./ssh_config /root/.ssh/config
32 32
 RUN chmod 600 /root/.ssh/config
33 33
 
34
+COPY ./kubeconfig /root/.kube/config
34 35
 COPY ./kubectl /usr/local/bin/
35 36
 COPY ./fluxd /usr/local/bin/
36 37
 

+ 12
- 0
docker/kubeconfig View File

@@ -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: []

Loading…
Cancel
Save