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

Commit

Permalink
Merge pull request #76 from Azure/convert-to-go-modules
Browse files Browse the repository at this point in the history
Convert to go modules and upgrade support to k8s 1.15
  • Loading branch information
jsturtevant authored Oct 31, 2019
2 parents d9adc12 + 230becd commit ef6a298
Show file tree
Hide file tree
Showing 2,643 changed files with 340,305 additions and 249,223 deletions.
298 changes: 152 additions & 146 deletions .azdevops/image-pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,147 +1,153 @@
# This pipeline tests the project and builds an image, which is pushed to a
# container registry for later use

trigger:
- master
pr:
- master
variables:
- group: 'Metrics Adapter'
jobs:
- job: buildAndTest
pool:
vmImage: 'ubuntu-16.04'
steps:

# Set up the Go workspace
# Go workspace setup from https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/go?view=azure-devops
- script: |
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(modulePath)'
shopt -s extglob
shopt -s dotglob
mv !(go) '$(modulePath)'
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
cd $(modulePath)
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
fi
displayName: 'Set up the Go workspace'
# make build
- script: 'make build'
workingDirectory: '$(modulePath)'
displayName: 'make build (Verify autogenerated scripts/Run tests/Build image)'
env:
VERSION: $(Build.BuildId)

# docker push
- script: 'make push'
workingDirectory: '$(modulePath)'
displayName: 'make push (docker push)'
env:
VERSION: $(Build.BuildId)
DOCKER_PASS: $(DOCKER_PASS)

- job: e2eTests
dependsOn: buildAndTest

# This will run this job 4 times with these 4 sets of variables
strategy:
matrix:
K8s10:
SERVICEBUS_SUBSCRIPTION_NAME: 'externalsub-10'
SERVICEBUS_QUEUE_NAME: 'externalq-10'
DOCKER_VERSION: '18.06.1~ce~3-0~ubuntu'
KUBERNETES_VERSION: '1.10.12'
K8s11:
SERVICEBUS_SUBSCRIPTION_NAME: 'externalsub-11'
SERVICEBUS_QUEUE_NAME: 'externalq-11'
DOCKER_VERSION: '17.03.3~ce-0~ubuntu-xenial'
KUBERNETES_VERSION: '1.11.6'
K8s12:
SERVICEBUS_SUBSCRIPTION_NAME: 'externalsub-12'
SERVICEBUS_QUEUE_NAME: 'externalq-12'
DOCKER_VERSION: '18.06.1~ce~3-0~ubuntu'
KUBERNETES_VERSION: '1.12.4'
K8s13:
SERVICEBUS_SUBSCRIPTION_NAME: 'externalsub-13'
SERVICEBUS_QUEUE_NAME: 'externalq-13'
DOCKER_VERSION: '18.06.1~ce~3-0~ubuntu'
KUBERNETES_VERSION: '1.13.1'

pool:
vmImage: 'ubuntu-16.04'
steps:

# Print version details
- script: |
echo "This build uses the following versions:"
echo "Kubernetes: $(KUBERNETES_VERSION)"
echo "Minikube: $(MINIKUBE_VERSION)"
echo "Helm: $(HELM_VERSION)"
echo "Docker: $(DOCKER_VERSION)"
displayName: 'Print version details'
# Set up the Go workspace
# Go workspace setup from https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/go?view=azure-devops
- script: |
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(modulePath)'
shopt -s extglob
shopt -s dotglob
mv !(go) '$(modulePath)'
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
cd $(modulePath)
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
fi
displayName: 'Set up the Go workspace'
# Install docker
- script: |
chmod +x *.sh
./install-docker.sh
workingDirectory: '$(modulePath)/.azdevops/0_install'
displayName: 'Install docker (must continue on error)'
# Install everything else needed
- script: |
./install-misc.sh
./install-crictl.sh
./install-minikube.sh
./install-helm.sh
workingDirectory: '$(modulePath)/.azdevops/0_install'
displayName: 'Install everything else'
# Start the cluster, get go packages, install tiller, set up metrics server, gen the local values file
- script: |
chmod +x *.sh
./start-cluster.sh
./go-get.sh
./check-cluster.sh
./init-tiller.sh
./gen-values-file.sh
workingDirectory: '$(modulePath)/.azdevops/1_setup'
displayName: 'Cluster set up, Go get, prep for adapter deployment'
env:
VERSION: $(Build.BuildId)
# Run hack/test-e2e.sh
- script: |
chmod +x *.sh
./run-e2e.sh
workingDirectory: '$(modulePath)/hack'
displayName: 'Run e2e test script (deploy adapter & test functionality)'
failOnStderr: true
env:
SERVICEBUS_CONNECTION_STRING: $(SERVICEBUS_CONNECTION_STRING)
SP_CLIENT_ID: $(SP_CLIENT_ID)
SP_TENANT_ID: $(SP_TENANT_ID)
# This pipeline tests the project and builds an image, which is pushed to a
# container registry for later use

trigger:
- master
pr:
- master
variables:
- group: 'Metrics Adapter'
jobs:
- job: buildAndTest
pool:
vmImage: 'ubuntu-16.04'
steps:

# Set up the Go workspace
# Go workspace setup from https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/go?view=azure-devops
- script: |
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(modulePath)'
shopt -s extglob
shopt -s dotglob
mv !(go) '$(modulePath)'
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
cd $(modulePath)
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
fi
displayName: 'Set up the Go workspace'
# make build
- script: 'make build'
workingDirectory: '$(modulePath)'
displayName: 'make build (Verify autogenerated scripts/Run tests/Build image)'
env:
VERSION: $(Build.BuildId)
GO111MODULE: on

# docker push
- script: 'make push'
workingDirectory: '$(modulePath)'
displayName: 'make push (docker push)'
env:
VERSION: $(Build.BuildId)
DOCKER_PASS: $(DOCKER_PASS)

- job: e2eTests
dependsOn: buildAndTest

# This will run this job 4 times with these 4 sets of variables
strategy:
matrix:
K8s11:
SERVICEBUS_SUBSCRIPTION_NAME: 'externalsub-11'
SERVICEBUS_QUEUE_NAME: 'externalq-11'
DOCKER_VERSION: '17.03.3~ce-0~ubuntu-xenial'
KUBERNETES_VERSION: '1.11.10'
K8s12:
SERVICEBUS_SUBSCRIPTION_NAME: 'externalsub-12'
SERVICEBUS_QUEUE_NAME: 'externalq-12'
DOCKER_VERSION: '18.06.1~ce~3-0~ubuntu'
KUBERNETES_VERSION: '1.12.4'
K8s13:
SERVICEBUS_SUBSCRIPTION_NAME: 'externalsub-13'
SERVICEBUS_QUEUE_NAME: 'externalq-13'
DOCKER_VERSION: '18.06.1~ce~3-0~ubuntu'
KUBERNETES_VERSION: '1.13.1'
K8s14:
SERVICEBUS_SUBSCRIPTION_NAME: 'externalsub-14'
SERVICEBUS_QUEUE_NAME: 'externalq-14'
DOCKER_VERSION: '18.06.1~ce~3-0~ubuntu'
KUBERNETES_VERSION: '1.14.8'
K8s15:
SERVICEBUS_SUBSCRIPTION_NAME: 'externalsub-15'
SERVICEBUS_QUEUE_NAME: 'externalq-15'
DOCKER_VERSION: '18.06.1~ce~3-0~ubuntu'
KUBERNETES_VERSION: '1.15.5'

pool:
vmImage: 'ubuntu-16.04'
steps:

# Print version details
- script: |
echo "This build uses the following versions:"
echo "Kubernetes: $(KUBERNETES_VERSION)"
echo "Minikube: $(MINIKUBE_VERSION)"
echo "Helm: $(HELM_VERSION)"
echo "Docker: $(DOCKER_VERSION)"
displayName: 'Print version details'
# Set up the Go workspace
# Go workspace setup from https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/go?view=azure-devops
- script: |
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(modulePath)'
shopt -s extglob
shopt -s dotglob
mv !(go) '$(modulePath)'
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
cd $(modulePath)
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
fi
displayName: 'Set up the Go workspace'
# Install docker
- script: |
chmod +x *.sh
./install-docker.sh
workingDirectory: '$(modulePath)/.azdevops/0_install'
displayName: 'Install docker (must continue on error)'
# Install everything else needed
- script: |
./install-misc.sh
./install-crictl.sh
./install-minikube.sh
./install-helm.sh
workingDirectory: '$(modulePath)/.azdevops/0_install'
displayName: 'Install everything else'
# Start the cluster, get go packages, install tiller, set up metrics server, gen the local values file
- script: |
chmod +x *.sh
./start-cluster.sh
./go-get.sh
./check-cluster.sh
./init-tiller.sh
./gen-values-file.sh
workingDirectory: '$(modulePath)/.azdevops/1_setup'
displayName: 'Cluster set up, Go get, prep for adapter deployment'
env:
VERSION: $(Build.BuildId)
# Run hack/test-e2e.sh
- script: |
chmod +x *.sh
./run-e2e.sh
workingDirectory: '$(modulePath)/hack'
displayName: 'Run e2e test script (deploy adapter & test functionality)'
failOnStderr: true
env:
SERVICEBUS_CONNECTION_STRING: $(SERVICEBUS_CONNECTION_STRING)
SP_CLIENT_ID: $(SP_CLIENT_ID)
SP_TENANT_ID: $(SP_TENANT_ID)
SP_CLIENT_SECRET: $(SP_CLIENT_SECRET)
10 changes: 7 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ version: 2
jobs:
build:
docker:
- image: circleci/golang:1.10.3
- image: circleci/golang:1.12.12
working_directory: /go/src/github.com/Azure/azure-k8s-metrics-adapter
steps:
- checkout
- setup_remote_docker
- run: |
echo 'export VERSION="$CIRCLE_WORKFLOW_ID"' >> $BASH_ENV
echo 'export IMAGE="public/k8s/metrics/adapter"' >> $BASH_ENV
echo 'export GO111MODULE=on' >> $BASH_ENV
- run:
name: install helm
command: .circleci/install-helm.sh
Expand All @@ -27,25 +28,28 @@ jobs:
- app.tar
build_pr:
docker:
- image: circleci/golang:1.10.3
- image: circleci/golang:1.12.12
working_directory: /go/src/github.com/Azure/azure-k8s-metrics-adapter
steps:
- checkout
- setup_remote_docker
- run: |
echo 'export GO111MODULE=on' >> $BASH_ENV
- run:
name: install helm
command: .circleci/install-helm.sh
- run: make build
deploy:
docker:
- image: circleci/golang:1.10.3
- image: circleci/golang:1.12.12
working_directory: /go/src/github.com/Azure/azure-k8s-metrics-adapter
steps:
- checkout
- setup_remote_docker
- run: |
echo 'export VERSION="$(if [ -z ${CIRCLE_TAG} ]; then echo "beta"; else echo "$CIRCLE_TAG"; fi)-$CIRCLE_BUILD_NUM"' >> $BASH_ENV
echo 'export IMAGE="public/k8s/metrics/adapter"' >> $BASH_ENV
echo 'export GO111MODULE=on' >> $BASH_ENV
- restore_cache:
keys:
- v1-{{ .Environment.CIRCLE_WORKFLOW_ID }}
Expand Down
12 changes: 11 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,26 @@ or contact [[email protected]](mailto:[email protected]) with any addi
## Development
To do development you will need:

- [Golang](https://golang.org/doc/install) - same as current [Kubernetes version ](https://github.com/kubernetes/community/blob/master/contributors/devel/development.md#go)
- [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)
- 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)
- [git](https://git-scm.com/downloads)
- [mercurial](https://www.mercurial-scm.org/downloads)

### Get the source
This project uses [go modules](https://blog.golang.org/using-go-modules).

If add the project to your `GOPATH` enable go modules before building.

```bash
go get github.com/Azure/azure-k8s-metrics-adapter
cd $GOPATH/src/github.com/Azure/azure-k8s-metrics-adapter
export GO111MODULE=on
```

Otherwise you can clone outside the project go modules will automatically be used if using go 1.12:

```
git clone https://github.com/Azure/azure-k8s-metrics-adapter.git
```

### Add your fork
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.11.11-alpine3.10 as builder
FROM golang:1.12.12-alpine3.10 as builder

WORKDIR /go/src/github.com/Azure/azure-k8s-metrics-adapter
COPY . .
Expand Down
Loading

0 comments on commit ef6a298

Please sign in to comment.