Skip to content

Commit 390b26e

Browse files
authored
Bind gce ssh key to prow (#1999)
1 parent ec1a081 commit 390b26e

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

prow/Makefile

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ all: build fmt vet test
1616

1717

1818
HOOK_VERSION = 0.84
19-
LINE_VERSION = 0.77
19+
LINE_VERSION = 0.78
2020
SINKER_VERSION = 0.5
2121
DECK_VERSION = 0.16
2222
SPLICE_VERSION = 0.15
@@ -44,6 +44,10 @@ JENKINS_ADDRESS_FILE = ${HOME}/jenkins-address
4444
# Service account key for bootstrap jobs.
4545
SERVICE_ACCOUNT_FILE = ${HOME}/service-account.json
4646

47+
# GCE ssh key for gce-e2e jobs
48+
SSH_KEY_PRIVATE = ${HOME}/ssh-private
49+
SSH_KEY_PUBLIC = ${HOME}/ssh-public
50+
4751
# Should probably move this to a script or something.
4852
create-cluster:
4953
gcloud -q container --project "$(PROJECT)" clusters create "$(CLUSTER)" --zone "$(ZONE)" --machine-type n1-standard-4 --num-nodes 4 --node-labels=role=prow --scopes "https://www.googleapis.com/auth/compute","https://www.googleapis.com/auth/devstorage.full_control","https://www.googleapis.com/auth/logging.write","https://www.googleapis.com/auth/servicecontrol","https://www.googleapis.com/auth/service.management" --network "default" --enable-cloud-logging --enable-cloud-monitoring
@@ -52,6 +56,7 @@ create-cluster:
5256
kubectl create secret generic oauth-token --from-file=oauth=$(OAUTH_SECRET_FILE)
5357
kubectl create secret generic jenkins-token --from-file=jenkins=$(JENKINS_SECRET_FILE)
5458
kubectl create secret generic service-account --from-file=service-account.json=$(SERVICE_ACCOUNT_FILE)
59+
kubectl create secret generic ssh-key-secret --from-file=ssh-private=$(SSH_KEY_PRIVATE) --from-file=ssh-public=$(SSH_KEY_PUBLIC)
5560
kubectl create configmap jenkins-address --from-file=jenkins-address=$(JENKINS_ADDRESS_FILE)
5661
kubectl create configmap config --from-file=config=config.yaml
5762
kubectl create configmap plugins --from-file=plugins=plugins.yaml

prow/cluster/hook_deployment.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ spec:
4141
- "--github-bot-name=k8s-ci-robot"
4242
env:
4343
- name: LINE_IMAGE
44-
value: "gcr.io/k8s-prow/line:0.77"
44+
value: "gcr.io/k8s-prow/line:0.78"
4545
- name: DRY_RUN
4646
value: "false"
4747
ports:

prow/cluster/horologium_deployment.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ spec:
3333
image: gcr.io/k8s-prow/horologium:0.0
3434
env:
3535
- name: LINE_IMAGE
36-
value: "gcr.io/k8s-prow/line:0.77"
36+
value: "gcr.io/k8s-prow/line:0.78"
3737
- name: DRY_RUN
3838
value: "false"
3939
volumeMounts:

prow/cluster/splice_deployment.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spec:
2424
- -log-json
2525
env:
2626
- name: LINE_IMAGE
27-
value: "gcr.io/k8s-prow/line:0.77"
27+
value: "gcr.io/k8s-prow/line:0.78"
2828
- name: DRY_RUN
2929
value: "false"
3030
volumes:

prow/cmd/line/main.go

+20-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func fields(c *testClient) logrus.Fields {
233233
// necessary.
234234
// We modify the pod's spec to have the build parameters such as PR number
235235
// passed in as environment variables. We also include the service account
236-
// secret.
236+
// secret and gce ssh keys.
237237
func (c *testClient) TestKubernetes() error {
238238
logrus.WithFields(fields(c)).Info("Starting pod.")
239239
buildID := getBuildID(*totURL, c.JobName)
@@ -301,13 +301,26 @@ func (c *testClient) TestKubernetes() error {
301301
Name: "GOOGLE_APPLICATION_CREDENTIALS",
302302
Value: "/etc/service-account/service-account.json",
303303
},
304+
kube.EnvVar{
305+
Name: "JENKINS_GCE_SSH_PRIVATE_KEY_FILE",
306+
Value: "/etc/ssh-key-secret/ssh-private.json",
307+
},
308+
kube.EnvVar{
309+
Name: "JENKINS_GCE_SSH_PUBLIC_KEY_FILE",
310+
Value: "/etc/ssh-key-secret/ssh-public.json",
311+
},
304312
)
305313
spec.Containers[i].VolumeMounts = append(spec.Containers[i].VolumeMounts,
306314
kube.VolumeMount{
307315
Name: "service",
308316
MountPath: "/etc/service-account",
309317
ReadOnly: true,
310318
},
319+
kube.VolumeMount{
320+
Name: "ssh",
321+
MountPath: "/etc/ssh-key-secret",
322+
ReadOnly: true,
323+
},
311324
kube.VolumeMount{
312325
Name: "cache-ssd",
313326
MountPath: "/root/.cache",
@@ -329,6 +342,12 @@ func (c *testClient) TestKubernetes() error {
329342
Name: "service-account",
330343
},
331344
},
345+
kube.Volume{
346+
Name: "ssh",
347+
Secret: &kube.SecretSource{
348+
Name: "ssh-key-secret",
349+
},
350+
},
332351
kube.Volume{
333352
Name: "cache-ssd",
334353
HostPath: &kube.HostPathSource{

0 commit comments

Comments
 (0)