Skip to content

Commit 8d8c60a

Browse files
authored
Merge pull request #139 from kbst/tf013
Upgrade to Terraform v0.13
2 parents b269128 + 131e601 commit 8d8c60a

File tree

37 files changed

+310
-173
lines changed

37 files changed

+310
-173
lines changed

.github/workflows/main.yml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ jobs:
2424
sudo chown -R `id -u`:`id -g` ./quickstart/_dist
2525
2626
- name: 'Upload artifacts'
27-
uses: actions/upload-artifact@v1
27+
uses: actions/upload-artifact@v2
2828
with:
2929
name: test-artifacts
3030
path: ./quickstart/_dist
3131

3232
build-image:
3333
runs-on: ubuntu-latest
34-
34+
needs: [build-test-artifacts]
3535
strategy:
3636
matrix:
3737
starter: ["multi-cloud", "aks", "eks", "gke" ,"kind"]
@@ -40,6 +40,12 @@ jobs:
4040
- name: 'Checkout'
4141
uses: actions/checkout@v1
4242

43+
- name: 'Download test-artifacts'
44+
uses: actions/download-artifact@v2
45+
with:
46+
name: test-artifacts
47+
path: ./quickstart/_dist
48+
4349
- name: 'Docker login'
4450
run: |
4551
echo ${{ secrets.DOCKER_AUTH }} | docker login --username kbstci --password-stdin
@@ -51,14 +57,14 @@ jobs:
5157
docker run \
5258
--rm \
5359
--privileged \
54-
-v `pwd`/oci:/tmp/work \
60+
-v `pwd`:/tmp/work \
5561
-v $HOME/.docker:/root/.docker \
5662
--entrypoint buildctl-daemonless.sh \
5763
moby/buildkit:master \
5864
build \
5965
--frontend dockerfile.v0 \
6066
--local context=/tmp/work \
61-
--local dockerfile=/tmp/work \
67+
--local dockerfile=/tmp/work/oci \
6268
--output type=image,name=kubestack/framework-dev:test-${{ github.sha }}-${{ matrix.starter }},push=true \
6369
--export-cache type=registry,ref=kubestack/framework-dev:buildcache-${{ matrix.starter }},push=true \
6470
--import-cache type=registry,ref=kubestack/framework-dev:buildcache-${{ matrix.starter }} \
@@ -74,13 +80,14 @@ jobs:
7480

7581
steps:
7682
- name: 'Download test-artifacts'
77-
uses: actions/download-artifact@v1
83+
uses: actions/download-artifact@v2
7884
with:
7985
name: test-artifacts
86+
path: ./quickstart/_dist
8087

8188
- name: 'Unzip ${{ matrix.starter }} quickstart'
8289
run: |
83-
unzip test-artifacts/kubestack-starter-${{ matrix.starter }}-*.zip
90+
unzip quickstart/_dist/kubestack-starter-${{ matrix.starter }}-*.zip
8491
8592
- name: 'Docker build'
8693
env:
@@ -109,7 +116,7 @@ jobs:
109116
sed -i 's/resource_group = ""/resource_group = "terraform-kubestack-testing"/g' config.auto.tfvars
110117
111118
# EKS: set region
112-
sed -i 's/region = ""/region = "eu-west-1"/g' providers.tf
119+
sed -i 's/region = ""/region = "eu-west-1"/g' providers.tf || true
113120
114121
# EKS: set cluster_availability_zones
115122
sed -i 's/cluster_availability_zones = ""/cluster_availability_zones = "eu-west-1a,eu-west-1b"/g' config.auto.tfvars
@@ -173,9 +180,10 @@ jobs:
173180

174181
steps:
175182
- name: 'Download test-artifacts'
176-
uses: actions/download-artifact@v1
183+
uses: actions/download-artifact@v2
177184
with:
178185
name: test-artifacts
186+
path: ./quickstart/_dist
179187

180188
- name: 'Docker login'
181189
run: |
@@ -188,7 +196,7 @@ jobs:
188196
run: |
189197
SOURCE_IMAGE=kubestack/framework-dev:test-${{ github.sha }}-${{ matrix.starter }}
190198
docker pull $SOURCE_IMAGE
191-
TARGET_IMAGE=$(cat test-artifacts/kubestack-starter-${{ matrix.starter }}/Dockerfile | sed 's/FROM //')
199+
TARGET_IMAGE=$(cat quickstart/_dist/kubestack-starter-${{ matrix.starter }}/Dockerfile | sed 's/FROM //')
192200
docker tag $SOURCE_IMAGE $TARGET_IMAGE
193201
docker push $TARGET_IMAGE
194202
@@ -204,9 +212,10 @@ jobs:
204212

205213
steps:
206214
- name: 'Download test-artifacts'
207-
uses: actions/download-artifact@v1
215+
uses: actions/download-artifact@v2
208216
with:
209217
name: test-artifacts
218+
path: ./quickstart/_dist
210219

211220
- name: 'Setup gcloud'
212221
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
@@ -215,12 +224,12 @@ jobs:
215224

216225
- name: 'Publish ${{ matrix.starter }} starter'
217226
run: |
218-
SOURCE_FILE=test-artifacts/kubestack-starter-${{ matrix.starter }}-${{ github.sha }}.zip
227+
SOURCE_FILE=quickstart/_dist/kubestack-starter-${{ matrix.starter }}-${{ github.sha }}.zip
219228
TARGET_BUCKET=dev.quickstart.kubestack.com
220229
if [[ $GITHUB_REF = refs/tags/v* ]]
221230
then
222231
VERSION=$(echo $GITHUB_REF | sed -e "s#^refs/tags/##")
223-
SOURCE_FILE=test-artifacts/kubestack-starter-${{ matrix.starter }}-${VERSION}.zip
232+
SOURCE_FILE=quickstart/_dist/kubestack-starter-${{ matrix.starter }}-${VERSION}.zip
224233
TARGET_BUCKET=quickstart.kubestack.com
225234
fi
226235
gsutil -m cp $SOURCE_FILE gs://$TARGET_BUCKET

Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
_all: dist build
2+
3+
GITHUB_REF := $(shell echo "refs/heads/"`git rev-parse --abbrev-ref HEAD`)
4+
GITHUB_SHA := $(shell echo `git rev-parse --verify HEAD^{commit}`)
5+
6+
dist:
7+
docker build -t actions_build_artifacts:$(GITHUB_SHA) .github/actions/build_artifacts/
8+
docker run --rm -e GITHUB_REF=$(GITHUB_REF) -e GITHUB_SHA=$(GITHUB_SHA) -v `pwd`/quickstart:/opt/quickstart:z actions_build_artifacts:$(GITHUB_SHA)
9+
10+
build: dist
11+
docker build --file oci/Dockerfile --progress plain -t kubestack/framework:local-$(GITHUB_SHA) .
12+
13+
test:
14+
cloud-build-local --substitutions=_KBST_AUTH_AWS=${KBST_AUTH_AWS},_KBST_AUTH_GCLOUD=${KBST_AUTH_GCLOUD},_KBST_AUTH_AZ=${KBST_AUTH_AZ},_GITHUB_REF=$(GITHUB_REF),_GITHUB_SHA=$(GITHUB_SHA) --dryrun=false --config cloudbuild-test.yaml .
15+
16+
test-cleanup:
17+
cloud-build-local --substitutions=_KBST_AUTH_AWS=${KBST_AUTH_AWS},_KBST_AUTH_GCLOUD=${KBST_AUTH_GCLOUD},_KBST_AUTH_AZ=${KBST_AUTH_AZ},_GITHUB_REF=$(GITHUB_REF),_GITHUB_SHA=$(GITHUB_SHA) --dryrun=false --config cloudbuild-cleanup.yaml .
18+
19+
providers:
20+
cloud-build-local --substitutions=_KBST_AUTH_AWS=${KBST_AUTH_AWS},_KBST_AUTH_GCLOUD=${KBST_AUTH_GCLOUD},_KBST_AUTH_AZ=${KBST_AUTH_AZ},_GITHUB_REF=$(GITHUB_REF),_GITHUB_SHA=$(GITHUB_SHA) --dryrun=false --config cloudbuild-providers.yaml .
21+
22+
shell: build
23+
docker run -ti --rm -e KBST_AUTH_AWS -e KBST_AUTH_AZ -e KBST_AUTH_GCLOUD -e HOME=/infra/tests/.user -v `pwd`:/infra:z --workdir /infra/tests kubestack/framework:local-$(GITHUB_SHA) bash

aws/_modules/eks/roles_master.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ POLICY
2020

2121
resource "aws_iam_role_policy_attachment" "master_cluster_policy" {
2222
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"
23-
role = aws_iam_role.master.name
23+
role = aws_iam_role.master.name
2424
}
2525

2626
resource "aws_iam_role_policy_attachment" "master_service_policy" {
2727
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSServicePolicy"
28-
role = aws_iam_role.master.name
28+
role = aws_iam_role.master.name
2929
}
3030

aws/_modules/eks/roles_worker.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ POLICY
2020

2121
resource "aws_iam_role_policy_attachment" "node_policy" {
2222
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy"
23-
role = aws_iam_role.node.name
23+
role = aws_iam_role.node.name
2424
}
2525

2626
resource "aws_iam_role_policy_attachment" "node_cni_policy" {
2727
policy_arn = "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"
28-
role = aws_iam_role.node.name
28+
role = aws_iam_role.node.name
2929
}
3030

3131
resource "aws_iam_role_policy_attachment" "node_container_registry_ro" {
3232
policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
33-
role = aws_iam_role.node.name
33+
role = aws_iam_role.node.name
3434
}
3535

3636
resource "aws_iam_instance_profile" "nodes" {

aws/_modules/eks/versions.tf

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11

22
terraform {
3-
required_version = ">= 0.12"
3+
required_providers {
4+
aws = {
5+
source = "hashicorp/aws"
6+
version = "~> 3.9.0"
7+
}
8+
9+
external = {
10+
source = "hashicorp/external"
11+
version = "~> 1.2.0"
12+
}
13+
14+
kubernetes = {
15+
source = "hashicorp/kubernetes"
16+
version = "~> 1.12.0"
17+
}
18+
}
19+
20+
required_version = ">= 0.13"
421
}

aws/cluster-local/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
terraform {
3-
required_version = ">= 0.12"
3+
required_version = ">= 0.13"
44
}

aws/cluster/providers.tf

Lines changed: 0 additions & 19 deletions
This file was deleted.

aws/cluster/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
terraform {
3-
required_version = ">= 0.12"
3+
required_version = ">= 0.13"
44
}

azurerm/_modules/aks/provider.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
provider "azurerm" {
2+
features {}
3+
}
4+
15
provider "kubernetes" {
26
alias = "aks"
37

@@ -12,4 +16,3 @@ provider "kubernetes" {
1216
azurerm_kubernetes_cluster.current.kube_config[0].cluster_ca_certificate,
1317
)
1418
}
15-

azurerm/_modules/aks/versions.tf

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
11

22
terraform {
3-
required_version = ">= 0.12"
3+
required_providers {
4+
azurerm = {
5+
source = "hashicorp/azurerm"
6+
version = "~> 2.23.0"
7+
}
8+
9+
azuread = {
10+
source = "hashicorp/azuread"
11+
version = "~> 0.11.0"
12+
}
13+
14+
external = {
15+
source = "hashicorp/external"
16+
version = "~> 1.2.0"
17+
}
18+
19+
kubernetes = {
20+
source = "hashicorp/kubernetes"
21+
version = "~> 1.12.0"
22+
}
23+
24+
random = {
25+
source = "hashicorp/random"
26+
version = "~> 2.3.0"
27+
}
28+
}
29+
30+
required_version = ">= 0.13"
431
}

0 commit comments

Comments
 (0)