Skip to content

Commit

Permalink
Fix deployment of infrastructure through Terraform (#47)
Browse files Browse the repository at this point in the history
* Pinned azurerm provider to specific version and adjusted parameters in module

* Added configuration to install newer Terraform version in cicd executor

* Changed OS architecture in circleci config file

* Added quotes to string

* Removed Terraform Orb and set new executor to install required Terraform version

* Changed working directory

* Changed executor image

* Restored circleci base image for the executor

* Removed unnecessary terraform commands

* Added required parameter in terraform file

* Updated kubernetes and orchestrator version and sku-tier

* Changed some variable names to what is expected by Terraform Cloud

* Removed default value in variables

* Extended cluster deletion to 3 hours

* Updated external-dns image tag

* Fixed Kubernetes version

* Added configuration to tag image
  • Loading branch information
giulio-giunta authored Dec 10, 2023
1 parent 28faac7 commit c09fe35
Show file tree
Hide file tree
Showing 7 changed files with 279 additions and 247 deletions.
48 changes: 26 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,68 @@
version: 2.1
orbs:
terraform: circleci/[email protected]
jobs:
terraform-cycle:
executor: terraform/default
docker:
- image: "cimg/base:stable"
steps:
- checkout
- setup_remote_docker:
version: 20.10.7
- run:
name: Create .terraformrc file locally
command: >-
echo "credentials \"app.terraform.io\" {token =
\"$TERRAFORM_TOKEN\"}" > $HOME/.terraformrc
- run:
- run:
name: Install Terraform cli
command: |
wget https://releases.hashicorp.com/terraform/1.4.2/terraform_1.4.2_linux_386.zip
unzip terraform_1.4.2_linux_386.zip
sudo mv terraform /usr/local/bin
- run:
name: Terraform cycle
command: |
cd aws/terraform-aws
terraform init -upgrade
terraform validate
terraform init
terraform plan
cd ../../azure/terraform-azure
terraform init -upgrade
terraform validate
terraform init
terraform plan
working_directory: ~/src
working_directory: ~/project

build-publish:
docker:
- image: 'cimg/base:stable'
- image: "cimg/base:stable"
auth:
username: $DOCKER_USERNAME
password: $DOCKER_PASSWORD
environment:
TAG: 0.1.<< pipeline.number >>
steps:
- checkout
- setup_remote_docker:
version: 20.10.7
version: 20.10.7
- run:
name: Build geekzone/infra image
name: Build geekzone/infra image
command: |
docker build -t geekzone/infra .
docker build -t geekzone/infra:$TAG .
- deploy:
name: Push geekzone/infra image to Docker Hub
command: |
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
docker push geekzone/infra
docker push geekzone/infra:$TAG
workflows:
main-infra:
jobs:
- terraform-cycle:
filters:
branches:
ignore:
- /junk-.*/
ignore:
- /junk-.*/
- build-publish:
requires:
- terraform-cycle
- terraform-cycle
filters:
branches:
ignore:
- /junk-.*/


ignore:
- /junk-.*/
46 changes: 23 additions & 23 deletions aws/k8s/external-dns/external-dns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ kind: ClusterRole
metadata:
name: external-dns
rules:
- apiGroups: [""]
resources: ["services","endpoints","pods"]
verbs: ["get","watch","list"]
- apiGroups: ["extensions","networking.k8s.io"]
resources: ["ingresses"]
verbs: ["get","watch","list"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["list", "watch"]
- apiGroups: [""]
resources: ["services", "endpoints", "pods"]
verbs: ["get", "watch", "list"]
- apiGroups: ["extensions", "networking.k8s.io"]
resources: ["ingresses"]
verbs: ["get", "watch", "list"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
Expand All @@ -28,9 +28,9 @@ roleRef:
kind: ClusterRole
name: external-dns
subjects:
- kind: ServiceAccount
name: external-dns
namespace: external-dns
- kind: ServiceAccount
name: external-dns
namespace: external-dns
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -50,14 +50,14 @@ spec:
spec:
serviceAccountName: external-dns
containers:
- name: external-dns
image: k8s.gcr.io/external-dns/external-dns:v0.7.6
args:
- --source=ingress # service is also possible
- --domain-filter=geek.zone # (optional) limit to only example.com domains; change to match the zone created above.
- --zone-id-filter=0a6922d1395d374729870d071e623aa0 # (optional) limit to a specific zone.
- --provider=cloudflare
- --cloudflare-proxied # (optional) enable the proxy feature of Cloudflare (DDOS protection, CDN...)
envFrom:
- secretRef:
name: external-dns-secrets
- name: external-dns
image: registry.k8s.io/external-dns/external-dns:v0.13.5
args:
- --source=ingress # service is also possible
- --domain-filter=geek.zone # (optional) limit to only example.com domains; change to match the zone created above.
- --zone-id-filter=0a6922d1395d374729870d071e623aa0 # (optional) limit to a specific zone.
- --provider=cloudflare
- --cloudflare-proxied # (optional) enable the proxy feature of Cloudflare (DDOS protection, CDN...)
envFrom:
- secretRef:
name: external-dns-secrets
46 changes: 23 additions & 23 deletions azure/k8s/external-dns/external-dns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ kind: ClusterRole
metadata:
name: external-dns
rules:
- apiGroups: [""]
resources: ["services","endpoints","pods"]
verbs: ["get","watch","list"]
- apiGroups: ["extensions","networking.k8s.io"]
resources: ["ingresses"]
verbs: ["get","watch","list"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["list", "watch"]
- apiGroups: [""]
resources: ["services", "endpoints", "pods"]
verbs: ["get", "watch", "list"]
- apiGroups: ["extensions", "networking.k8s.io"]
resources: ["ingresses"]
verbs: ["get", "watch", "list"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
Expand All @@ -28,9 +28,9 @@ roleRef:
kind: ClusterRole
name: external-dns
subjects:
- kind: ServiceAccount
name: external-dns
namespace: external-dns
- kind: ServiceAccount
name: external-dns
namespace: external-dns
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -50,14 +50,14 @@ spec:
spec:
serviceAccountName: external-dns
containers:
- name: external-dns
image: k8s.gcr.io/external-dns/external-dns:v0.7.6
args:
- --source=ingress # service is also possible
- --domain-filter=geek.zone # (optional) limit to only example.com domains; change to match the zone created above.
- --zone-id-filter=0a6922d1395d374729870d071e623aa0 # (optional) limit to a specific zone.
- --provider=cloudflare
- --cloudflare-proxied # (optional) enable the proxy feature of Cloudflare (DDOS protection, CDN...)
envFrom:
- secretRef:
name: external-dns-secrets
- name: external-dns
image: registry.k8s.io/external-dns/external-dns:v0.13.5
args:
- --source=ingress # service is also possible
- --domain-filter=geek.zone # (optional) limit to only example.com domains; change to match the zone created above.
- --zone-id-filter=0a6922d1395d374729870d071e623aa0 # (optional) limit to a specific zone.
- --provider=cloudflare
- --cloudflare-proxied # (optional) enable the proxy feature of Cloudflare (DDOS protection, CDN...)
envFrom:
- secretRef:
name: external-dns-secrets
Loading

0 comments on commit c09fe35

Please sign in to comment.