File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11sudo : false
22services :
33 - docker
4+
45install :
56 - mkdir -p $HOME/bin
67 - curl -Lo $HOME/bin/skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64
78 - curl -Lo $HOME/bin/container-structure-test https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64
9+ - curl -Lo $HOME/bin/kind https://github.com/kubernetes-sigs/kind/releases/download/v0.7.0/kind-linux-amd64
10+ - curl -Lo $HOME/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.18.0/bin/linux/amd64/kubectl
811 - chmod +x $HOME/bin/*
912 - export PATH=$HOME/bin:$PATH
13+
1014script :
1115 - skaffold build -p local
16+ # we had `run-its.sh` in`after_success` but it doesn't cause failures
17+ # `kind create cluster` is very verbose
18+ - kind create cluster -q && kind get kubeconfig > /tmp/kube.config && KUBECONFIG=/tmp/kube.config bash ./run-its.sh
Original file line number Diff line number Diff line change @@ -35,3 +35,13 @@ should download the necessary files into the container image. The
3535image's entrypoint should then copy those files into place at
3636` /dbg/<runtime> ` . The image should be added to the ` skaffold.yaml `
3737and referenced within ` test/k8s-test-installation.yaml ` .
38+
39+ ### Testing
40+
41+ Integration tests are found in ` integration/ ` . These build and
42+ launch applications as pods that are similar to the transformed
43+ form produced by ` skaffold debug ` . To run:
44+
45+ ``` sh
46+ sh run-its.sh
47+ ```
Original file line number Diff line number Diff line change 1+ ARG GOVERSION=1.14
2+ FROM golang:${GOVERSION} as builder
3+ COPY main.go .
4+ RUN go build -gcflags="all=-N -l" -o /app main.go
5+
6+ FROM gcr.io/distroless/base
7+ CMD ["./app" ]
8+ ENV GOTRACEBACK=single
9+ COPY --from=builder /app .
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "fmt"
5+ "log"
6+ "net/http"
7+ )
8+
9+ func main () {
10+ http .HandleFunc ("/" , hello )
11+
12+ log .Println ("Listening on port 8080" )
13+ http .ListenAndServe (":8080" , nil )
14+ }
15+
16+ func hello (w http.ResponseWriter , r * http.Request ) {
17+ fmt .Fprintf (w , "Hello, World!" )
18+ }
Original file line number Diff line number Diff line change 1+ # Simple RBAC required to enable use of `kubectl port-forward`
2+ # from within a contaier.
3+ apiVersion : rbac.authorization.k8s.io/v1beta1
4+ kind : ClusterRoleBinding
5+ metadata :
6+ name : default-rbac
7+ subjects :
8+ - kind : ServiceAccount
9+ # Reference to upper's `metadata.name`
10+ name : default
11+ # Reference to upper's `metadata.namespace`
12+ namespace : default
13+ roleRef :
14+ kind : ClusterRole
15+ name : cluster-admin
16+ apiGroup : rbac.authorization.k8s.io
Original file line number Diff line number Diff line change 1+ apiVersion : v1
2+ kind : Pod
3+ metadata :
4+ name : go113pod
5+ spec :
6+ containers :
7+ - name : go113app
8+ image : go113app
9+ args :
10+ - /dbg/go/bin/dlv
11+ - exec
12+ - --log
13+ - --headless
14+ - --continue
15+ - --accept-multiclient
16+ - --listen=localhost:56286
17+ - --api-version=2
18+ - ./app
19+ ports :
20+ - containerPort : 8080
21+ - containerPort : 56286
22+ name : dlv
23+ readinessProbe :
24+ httpGet :
25+ path : /
26+ port : 8080
27+ volumeMounts :
28+ - mountPath : /dbg
29+ name : go-debugging-support
30+ initContainers :
31+ - image : gcr.io/gcp-dev-tools/duct-tape/go
32+ name : install-go-support
33+ resources : {}
34+ volumeMounts :
35+ - mountPath : /dbg
36+ name : go-debugging-support
37+ volumes :
38+ - emptyDir : {}
39+ name : go-debugging-support
40+
41+ ---
42+ apiVersion : batch/v1
43+ kind : Job
44+ metadata :
45+ name : connect-to-go113
46+ labels :
47+ project : container-debug-support
48+ type : integration-test
49+ spec :
50+ ttlSecondsAfterFinished : 10
51+ backoffLimit : 1
52+ template :
53+ spec :
54+ restartPolicy : Never
55+ volumes :
56+ - name : kubectl
57+ emptyDir : {}
58+ initContainers :
59+ - name : copy-kubectl
60+ image : bitnami/kubectl
61+ command : [sh, -c, 'cp -p /opt/bitnami/kubectl/bin/kubectl /kubectl/kubectl']
62+ volumeMounts :
63+ - mountPath : /kubectl
64+ name : kubectl
65+ containers :
66+ - name : dlv-to-go113
67+ image : gcr.io/gcp-dev-tools/duct-tape/go
68+ command : [sh, -c, 'sleep 5;
69+ /kubectl/kubectl port-forward pod/go113pod 56286:56286 &
70+ sleep 2;
71+ (echo bt; echo exit -c) > init.txt;
72+ set -x;
73+ /duct-tape/go/bin/dlv connect --init init.txt localhost:56286']
74+ volumeMounts :
75+ - mountPath : /kubectl
76+ name : kubectl
77+
78+
Original file line number Diff line number Diff line change 1+ apiVersion : v1
2+ kind : Pod
3+ metadata :
4+ name : go114pod
5+ spec :
6+ containers :
7+ - name : go114app
8+ image : go114app
9+ args :
10+ - /dbg/go/bin/dlv
11+ - exec
12+ - --log
13+ - --headless
14+ - --continue
15+ - --accept-multiclient
16+ - --listen=localhost:56286
17+ - --api-version=2
18+ - ./app
19+ ports :
20+ - containerPort : 8080
21+ - containerPort : 56286
22+ name : dlv
23+ readinessProbe :
24+ httpGet :
25+ path : /
26+ port : 8080
27+ volumeMounts :
28+ - mountPath : /dbg
29+ name : go-debugging-support
30+ initContainers :
31+ - image : gcr.io/gcp-dev-tools/duct-tape/go
32+ name : install-go-support
33+ resources : {}
34+ volumeMounts :
35+ - mountPath : /dbg
36+ name : go-debugging-support
37+ volumes :
38+ - emptyDir : {}
39+ name : go-debugging-support
40+
41+ ---
42+ apiVersion : batch/v1
43+ kind : Job
44+ metadata :
45+ name : connect-to-go114
46+ labels :
47+ project : container-debug-support
48+ type : integration-test
49+ spec :
50+ ttlSecondsAfterFinished : 10
51+ backoffLimit : 1
52+ template :
53+ spec :
54+ restartPolicy : Never
55+ volumes :
56+ - name : kubectl
57+ emptyDir : {}
58+ initContainers :
59+ - name : copy-kubectl
60+ image : bitnami/kubectl
61+ command : [sh, -c, 'cp -p /opt/bitnami/kubectl/bin/kubectl /kubectl/kubectl']
62+ volumeMounts :
63+ - mountPath : /kubectl
64+ name : kubectl
65+ containers :
66+ - name : dlv-to-go114
67+ image : gcr.io/gcp-dev-tools/duct-tape/go
68+ command : [sh, -c, 'sleep 5;
69+ /kubectl/kubectl port-forward pod/go114pod 56286:56286 &
70+ sleep 2;
71+ (echo bt; echo exit -c) > init.txt;
72+ set -x;
73+ /duct-tape/go/bin/dlv connect --init init.txt localhost:56286']
74+ volumeMounts :
75+ - mountPath : /kubectl
76+ name : kubectl
77+
78+
Original file line number Diff line number Diff line change 1+ apiVersion : v1
2+ kind : Pod
3+ metadata :
4+ name : nodejs12pod
5+ spec :
6+ containers :
7+ - name : nodejs12app
8+ image : nodejs12app
9+ env :
10+ - name : NODE_DEBUG
11+ value : " --inspect=9229"
12+ - name : PATH
13+ value : " /dbg/nodejs/bin:/usr/local/bin:/usr/bin:/bin"
14+ ports :
15+ - containerPort : 3000
16+ - containerPort : 9229
17+ name : devtools
18+ readinessProbe :
19+ httpGet :
20+ path : /
21+ port : 3000
22+ volumeMounts :
23+ - mountPath : /dbg
24+ name : node-debugging-support
25+ initContainers :
26+ - image : gcr.io/gcp-dev-tools/duct-tape/nodejs
27+ name : install-node-support
28+ resources : {}
29+ volumeMounts :
30+ - mountPath : /dbg
31+ name : node-debugging-support
32+ volumes :
33+ - emptyDir : {}
34+ name : node-debugging-support
35+
36+ ---
37+ apiVersion : batch/v1
38+ kind : Job
39+ metadata :
40+ name : connect-to-nodejs12
41+ labels :
42+ project : container-debug-support
43+ type : integration-test
44+ spec :
45+ ttlSecondsAfterFinished : 10
46+ backoffLimit : 1
47+ template :
48+ spec :
49+ restartPolicy : Never
50+ containers :
51+ - name : verify-nodejs12
52+ image : bitnami/kubectl
53+ command : [sh, -c, 'sleep 5;
54+ kubectl port-forward pod/nodejs12pod 9229:9229 &
55+ sleep 2;
56+ set -x;
57+ curl -i localhost:9229/json']
58+
59+
Original file line number Diff line number Diff line change 1+ ARG NODEVERSION
2+ FROM node:${NODEVERSION}-alpine3.10
3+
4+ USER node
5+ RUN mkdir /home/node/app
6+ WORKDIR /home/node/app
7+
8+ EXPOSE 3000
9+ ARG ENV=production
10+ ENV NODE_ENV $ENV
11+ CMD npm run $NODE_ENV
12+
13+ COPY --chown=node:node package* ./
14+ RUN npm ci
15+ COPY --chown=node:node . .
You can’t perform that action at this time.
0 commit comments