diff --git a/spec/fixtures/output/k8s/pod_yml_subpath_configmap.yml b/spec/fixtures/output/k8s/pod_yml_subpath_configmap.yml index e26197441..c5bd3a295 100644 --- a/spec/fixtures/output/k8s/pod_yml_subpath_configmap.yml +++ b/spec/fixtures/output/k8s/pod_yml_subpath_configmap.yml @@ -26,8 +26,20 @@ spec: imagePullPolicy: IfNotPresent workingDir: "/my/home" env: + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: USER + value: "testuser" + - name: UID + value: "1001" - name: HOME value: "/my/home" + - name: GROUP + value: "testgroup" + - name: GID + value: "1002" - name: PATH value: "/usr/bin:/usr/local/bin" command: @@ -60,6 +72,23 @@ spec: initContainers: - name: "init-1" image: "busybox:latest" + env: + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: USER + value: "testuser" + - name: UID + value: "1001" + - name: HOME + value: "/my/home" + - name: GROUP + value: "testgroup" + - name: GID + value: "1002" + - name: PATH + value: "/usr/bin:/usr/local/bin" command: - "/bin/ls" - "-lrt" diff --git a/spec/job/adapters/kubernetes/batch_spec.rb b/spec/job/adapters/kubernetes/batch_spec.rb index bbe81ff75..db7ff903d 100644 --- a/spec/job/adapters/kubernetes/batch_spec.rb +++ b/spec/job/adapters/kubernetes/batch_spec.rb @@ -450,16 +450,10 @@ def build_script(opts = {}) image: 'ruby:2.5', command: 'rake spec', port: 8080, - env: [ - { - name: 'HOME', - value: '/my/home' - }, - { - name: 'PATH', - value: '/usr/bin:/usr/local/bin' - } - ], + env: { + HOME: '/my/home', + PATH: '/usr/bin:/usr/local/bin' + }, memory: '6Gi', cpu: '4', working_dir: '/my/home', @@ -495,8 +489,8 @@ def build_script(opts = {}) allow(@basic_batch).to receive(:generate_id).with('rspec-test').and_return('rspec-test-123') allow(@basic_batch).to receive(:username).and_return('testuser') - allow(@basic_batch).to receive(:run_as_user).and_return(1001) - allow(@basic_batch).to receive(:run_as_group).and_return(1002) + allow(@basic_batch).to receive(:user).and_return(User.new(dir: '/home/testuser', uid: 1001, gid: 1002)) + allow(@basic_batch).to receive(:group).and_return('testgroup') # make sure it get's templated right, also helpful in debugging bc # it'll show a better diff than the test below.