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

Commit c11c269

Browse files
committed
Add devenv for building/testing/validating under Docker
1 parent 44df44f commit c11c269

10 files changed

+128
-88
lines changed

.dockerignore

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
./acsengine
2-
./acsengine.exe
1+
acs-engine
2+
acs-engine.exe
3+
_output/
4+
.git/

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* -crlf

.gitignore

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
*.anthony.json
2-
deployVM0.ps1
3-
noparams.json
4-
output*
51
acs-engine.exe
62
acs-engine
73
_output/

Dockerfile

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
FROM buildpack-deps:xenial
22

3+
ENV GO_VERSION 1.7.3
4+
ENV KUBECTL_VERSION 1.4.4
5+
ENV AZURE_CLI_VERSION 0.1.0b8
6+
37
RUN apt-get update \
4-
&& apt-get -y upgrade \
5-
&& apt-get -y install python-pip make build-essential curl openssl vim jq \
6-
&& rm -rf /var/lib/apt/lists/*
8+
&& apt-get -y upgrade \
9+
&& apt-get -y install python-pip make build-essential curl openssl vim jq \
10+
&& rm -rf /var/lib/apt/lists/*
711

8-
RUN curl 'https://godeb.s3.amazonaws.com/godeb-amd64.tar.gz' > /tmp/godeb.tar.gz \
9-
&& (cd /tmp/; tar zvxf godeb.tar.gz; ./godeb install 1.7.3)
12+
RUN mkdir /tmp/godeb \
13+
&& curl "https://godeb.s3.amazonaws.com/godeb-amd64.tar.gz" > /tmp/godeb/godeb.tar.gz \
14+
&& (cd /tmp/godeb; tar zvxf godeb.tar.gz; ./godeb install "${GO_VERSION}") \
15+
&& rm -rf /tmp/godeb
1016

11-
RUN pip install azure-cli==0.1.0b8
17+
RUN pip install "azure-cli==${AZURE_CLI_VERSION}"
1218

13-
RUN curl https://storage.googleapis.com/kubernetes-release/release/v1.4.4/bin/linux/amd64/kubectl > /usr/local/bin/kubectl \
14-
&& chmod +x /usr/local/bin/kubectl
19+
RUN curl "https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl" > /usr/local/bin/kubectl \
20+
&& chmod +x /usr/local/bin/kubectl
1521

1622
ENV GOPATH /gopath
1723
ENV PATH "${PATH}:${GOPATH}/bin"

Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
.NOTPARALLEL:
22

33
build:
4-
go generate -v
4+
go get .
5+
go generate -v ./...
56
go build -v
67

78
test:
@@ -16,7 +17,6 @@ lint:
1617

1718
ci: validate-generated build test lint
1819

19-
dev:
20-
docker build -t acs-engine .
21-
docker run -it -v `pwd`:/acs-engine -w /acs-engine acs-engine /bin/bash
20+
devenv:
21+
./scripts/devenv.sh
2222

README.md

+85-54
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,115 @@
1-
# ACSEngine - Template generator
1+
# Azure Container Service ARM Template Generator
22

3-
Template generator builds a custom template based on user requirements. Examples exist under clusterdefinitions folder.
3+
## Overview
44

5-
# Building the Application
5+
`acs-engine` is a tool that produces ARM (Azure Resource Manager) templates for deploying various container orchestrators into Azure.
6+
The input to the tool is a cluster definition. The cluster definition is very similar to (in many cases the same as) the ARM template
7+
syntax used to deploy an Azure Container Service cluster.
68

7-
To build the application:
9+
## Development (Docker)
810

9-
1. set $GOPATH (example c:\gopath)
10-
(under Windows `SET GOPATH=c:\gopath`)
11-
2. `go get gopkg.in/yaml.v2`
12-
3. `go get github.com/ghodss/yaml`
13-
4. `cd $GOPATH/github.com/Azure/acs-engine`
14-
5. `go build` to produce the acsengine binary
11+
The easiest way to get started developing on `acs-engine` is to use Docker.
12+
If you already have Docker or "Docker for {Windows,Mac}" then you can get started
13+
without needing to install anything extra.
1514

16-
# Developer Instructions
15+
* Windows (PowerShell): `.\scripts\devenv.ps1`
16+
* Linux (bash): `.\scripts\devenv.sh`
1717

18-
If you want to develop and submit changes, follow these additional steps:
18+
This setup mounts the `acs-engine` source directory as a volume into the Docker container.
19+
This means that you can edit your source code normally in your favorite editor on your
20+
machine, while still being able to compile and test inside of the Docker container (the
21+
same environment used in our Continuous Integration system).
1922

20-
1. Add $GOPATH\bin to your path
21-
(under Windows `SET PATH=%PATH%;%GOPATH%\bin`)
22-
2. `go get -u github.com/jteeuwen/go-bindata`
23+
[Here's a quick demo video showing the dev/build/test cycle with this setup.](https://www.youtube.com/watch?v=lc6UZmqxQMs)
2324

24-
Then everytime you adjust content in parts directory:
25+
## Development (Native)
2526

26-
1. `cd $GOPATH/github.com/Azure/acs-engine/pkg/acsengine`
27-
2. `go generate` to generate source files needed
28-
3. `cd $GOPATH/github.com/Azure/acs-engine`
29-
4. `go build` to produce the acsengine binary
27+
### Requirements
28+
- PowerShell (Windows)
29+
- `bash` + `make` (Linux)
30+
- `git`
31+
- `go` (with a properly configured GOPATH)
3032

31-
# Generating a Template
33+
### Building (Linux)
3234

33-
Once build run the generator with the command ```./acsengine
34-
CLUSTER_DEFINITION_FILE``` where ```CLUSTER_DEFINITION_FILE``` is the
35-
path to the cluster definition you want to use. The application
36-
outputs therequired ARM template. This can be piped to a file for
37-
later use (see below).
35+
```shell
36+
make build
37+
```
38+
39+
### Building (Windows, PowerShell)
3840

39-
There are some example definition files in the folder `clusterdefinitions`.
41+
```shell
42+
cd ${env:GOPATH}/github.com/Azure/acs-engine
43+
go get .
44+
go build .
45+
```
4046

41-
# Using a Template
4247

43-
Generated templates can be deployed using the Azure CLI or Powershell.
48+
## Contributing
4449

45-
## Deploying with Powershell
50+
Please follow these instructions before submitting a PR:
4651

47-
To deploy an ACS instance using Powershell and your generated template
48-
run the following two commands:
52+
1. Execute `make ci` to run the checkin validation tests.
4953

50-
``` Powershell
51-
New-AzureRmResourceGroup -Name <RESOURCE_GROUP_NAME> -Location <LOCATION> -Force
52-
New-AzureRmResourceGroupDeployment -Name <DEPLOYMENT_NAME> -ResourceGroupName <RESOURCE_GROUP_NAME> RGName -TemplateFile <TEMPLATE_FILE>
53-
```
54+
2. Manually test deployments if you are making modifications to the templates.
55+
For example, if you have to change the expected resulting templates then you
56+
should deploy the relevant example cluster definitions to ensure you're not
57+
introducing any sort of regression.
5458

55-
## Deploying with Azure CLI
59+
## Usage (Template Generation)
5660

57-
To deploy an ACS instance using the Azure CLI and your generated
58-
template run the following two commands:
61+
Usage is best demonstrated with an example:
5962

60-
``` bash
61-
azure group create <RESOURCE_GROUP_NAME> <LOCATION>
62-
azure group deployment create <RESOURCE_GROUP_NAME> <DEPLOYMENT NAME> -f <TEMPLATE_FILE>
63+
```shell
64+
$ vim examples/kubernetes.classic.json
6365

66+
# insert your preferred, unique DNS prefix
67+
# insert your SSH public key
68+
69+
$ ./acs-engine examples/kubernetes.classic.json
6470
```
6571

66-
# Using a Docker container
72+
This produces a new directory inside `_output/` that contains an ARM template
73+
for deploying Kubernetes into Azure. (In the case of Kubernetes, some additional
74+
needed assets are generated and placed in the output directory.)
75+
76+
## Usage (Deployment)
6777

68-
The ```scripts``` directory contains helper scripts that will assist
69-
with the using a Docker container to work with the appication.
78+
Generated templates can be deployed using
79+
[the Azure CLI](https://github.com/Azure/azure-cli) or
80+
[Powershell](https://github.com/Azure/azure-powershell).
7081

71-
## dev.sh
82+
### Deploying with Azure CLI
7283

73-
Run a Go container with the application source code mounted into the
74-
container. You can edit the code in your favorite editor on the client
75-
while building and running the container.
84+
```bash
85+
$ az login
7686

77-
## generate.sh
87+
$ az account set --name "<SUBSCRIPTION NAME OR ID>"
7888

79-
Generate a template from a given configuration and store it in the
80-
```generated``` folder. For example, to generate a Swarm template use:
89+
$ az group create \
90+
--name="<RESOURCE_GROUP_NAME>" \
91+
--location="<LOCATION>"
8192

82-
``` bash
83-
./scripts/generate.sh swarm.json
93+
$ az group deployment create \
94+
--name="<DEPLOYMENT NAME>" \
95+
--resource-group="<RESOURCE_GROUP_NAME>" \
96+
--template-file="./_output/<INSTANCE>/azuredeploy.json"
8497
```
98+
99+
### Deploying with Powershell
100+
101+
```powershell
102+
Add-AzureRmAccount
103+
104+
Select-AzureRmSubscription -SubscriptionID <SUBSCRIPTION_ID>
105+
106+
New-AzureRmResourceGroup `
107+
-Name <RESOURCE_GROUP_NAME> `
108+
-Location <LOCATION>
109+
110+
New-AzureRmResourceGroupDeployment `
111+
-Name <DEPLOYMENT_NAME> `
112+
-ResourceGroupName <RESOURCE_GROUP_NAME> `
113+
-TemplateFile _output\<INSTANCE>\azuredeploy.json
114+
```
115+

scripts/dev.sh

-4
This file was deleted.

scripts/devenv.ps1

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
$pwd = (Get-Location).Path
2+
3+
docker build --pull -t acs-engine .
4+
docker run -it `
5+
-v ${pwd}:/gopath/src/github.com/Azure/acs-engine `
6+
-w /gopath/src/github.com/Azure/acs-engine `
7+
acs-engine /bin/bash
8+

scripts/devenv.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu -o pipefail
4+
set -x
5+
6+
docker build --pull -t acs-engine .
7+
8+
docker run -it \
9+
-v `pwd`:/gopath/src/github.com/Azure/acs-engine \
10+
-w /gopath/src/github.com/Azure/acs-engine \
11+
acs-engine /bin/bash
12+

scripts/generate.sh

-12
This file was deleted.

0 commit comments

Comments
 (0)