Update terraform build images
This commit is contained in:
parent
6c633ee581
commit
8683d2c2c6
13 changed files with 55 additions and 45 deletions
|
@ -41,7 +41,6 @@ fi
|
||||||
export DOCKER_CLI_EXPERIMENTAL=enabled
|
export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--load \
|
--load \
|
||||||
--no-cache \
|
|
||||||
--platform linux/amd64 \
|
--platform linux/amd64 \
|
||||||
--tag build-nginx-terraform $DIR/images/nginx
|
--tag build-nginx-terraform $DIR/images/nginx
|
||||||
|
|
||||||
|
|
|
@ -1 +1,9 @@
|
||||||
*.tfvars
|
*.tfvars
|
||||||
|
*.tfvars
|
||||||
|
.terraform*
|
||||||
|
terraform*
|
||||||
|
*.tfstate
|
||||||
|
*.tfstate.backup
|
||||||
|
id_rsa*
|
||||||
|
aws.tfvars
|
||||||
|
env.tfvars
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
FROM us.gcr.io/k8s-artifacts-prod/build-image/debian-base-amd64:v2.1.0
|
FROM us.gcr.io/k8s-artifacts-prod/build-image/debian-base-amd64:v2.1.0
|
||||||
|
|
||||||
ENV TERRAFORM_VERSION 0.12.19
|
ENV TERRAFORM_VERSION 0.12.26
|
||||||
|
|
||||||
RUN clean-install \
|
RUN clean-install \
|
||||||
bash \
|
bash \
|
||||||
|
@ -8,6 +8,7 @@ RUN clean-install \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
unzip \
|
unzip \
|
||||||
git \
|
git \
|
||||||
|
python3 \
|
||||||
openssh-client
|
openssh-client
|
||||||
|
|
||||||
RUN curl -sSL -o /terraform.zip "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" \
|
RUN curl -sSL -o /terraform.zip "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" \
|
||||||
|
|
|
@ -34,16 +34,10 @@ source_tfvars /tmp/env
|
||||||
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
apt -q=3 update
|
apt update
|
||||||
|
apt dist-upgrade --yes
|
||||||
|
|
||||||
apt -q=3 dist-upgrade --yes
|
apt install \
|
||||||
|
|
||||||
add-apt-repository universe --yes
|
|
||||||
add-apt-repository multiverse --yes
|
|
||||||
|
|
||||||
apt -q=3 update
|
|
||||||
|
|
||||||
apt -q=3 install \
|
|
||||||
apt-transport-https \
|
apt-transport-https \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
curl \
|
curl \
|
||||||
|
@ -58,9 +52,8 @@ add-apt-repository \
|
||||||
$(lsb_release -cs) \
|
$(lsb_release -cs) \
|
||||||
stable" --yes
|
stable" --yes
|
||||||
|
|
||||||
apt -q=3 update
|
apt update
|
||||||
|
apt install docker-ce --yes
|
||||||
apt -q=3 install docker-ce --yes
|
|
||||||
|
|
||||||
echo ${docker_password} | docker login -u ${docker_username} --password-stdin quay.io
|
echo ${docker_password} | docker login -u ${docker_username} --password-stdin quay.io
|
||||||
|
|
|
@ -35,8 +35,14 @@ trap 'catch $? $LINENO' ERR
|
||||||
|
|
||||||
terraform init
|
terraform init
|
||||||
|
|
||||||
|
GET_UNTIL_VALID="
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
two_hours_from_now = datetime.utcnow() + timedelta(hours=2)
|
||||||
|
print(two_hours_from_now.strftime('%Y-%m-%dT%H:%M:%SZ'))
|
||||||
|
"
|
||||||
|
|
||||||
# destroy spot instance after two hours
|
# destroy spot instance after two hours
|
||||||
EC2_VALID_UNTIL=$(date -d "+2 hours" +%Y-%m-%dT%H:%M:%SZ)
|
EC2_VALID_UNTIL=$(python3 -c "$GET_UNTIL_VALID")
|
||||||
|
|
||||||
terraform plan \
|
terraform plan \
|
||||||
-var-file /root/aws.tfvars \
|
-var-file /root/aws.tfvars \
|
||||||
|
|
|
@ -165,8 +165,8 @@ resource "aws_spot_instance_request" "build_worker" {
|
||||||
}
|
}
|
||||||
|
|
||||||
provisioner "file" {
|
provisioner "file" {
|
||||||
source = "build-ingress-controller.sh"
|
source = "build.sh"
|
||||||
destination = "/tmp/build-ingress-controller.sh"
|
destination = "/tmp/build.sh"
|
||||||
}
|
}
|
||||||
|
|
||||||
provisioner "file" {
|
provisioner "file" {
|
||||||
|
@ -177,8 +177,8 @@ resource "aws_spot_instance_request" "build_worker" {
|
||||||
provisioner "remote-exec" {
|
provisioner "remote-exec" {
|
||||||
inline = [
|
inline = [
|
||||||
"echo Building ingress controller images...",
|
"echo Building ingress controller images...",
|
||||||
"chmod +x /tmp/build-ingress-controller.sh",
|
"chmod +x /tmp/build.sh",
|
||||||
"sudo /tmp/build-ingress-controller.sh",
|
"sudo /tmp/build.sh",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ variable "ssh_public_key_path" {
|
||||||
|
|
||||||
variable "instance_type" {
|
variable "instance_type" {
|
||||||
description = "EC2 instance"
|
description = "EC2 instance"
|
||||||
default = "c5.18xlarge"
|
default = "c5.xlarge"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "project_tag" {
|
variable "project_tag" {
|
||||||
|
|
|
@ -1 +1,8 @@
|
||||||
*.tfvars
|
*.tfvars
|
||||||
|
.terraform*
|
||||||
|
terraform*
|
||||||
|
*.tfstate
|
||||||
|
*.tfstate.backup
|
||||||
|
id_rsa*
|
||||||
|
aws.tfvars
|
||||||
|
env.tfvars
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
FROM us.gcr.io/k8s-artifacts-prod/build-image/debian-base-amd64:v2.1.0
|
FROM us.gcr.io/k8s-artifacts-prod/build-image/debian-base-amd64:v2.1.0
|
||||||
|
|
||||||
ENV TERRAFORM_VERSION 0.12.19
|
ENV TERRAFORM_VERSION 0.12.26
|
||||||
|
|
||||||
RUN clean-install \
|
RUN clean-install \
|
||||||
bash \
|
bash \
|
||||||
|
@ -8,6 +8,7 @@ RUN clean-install \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
unzip \
|
unzip \
|
||||||
git \
|
git \
|
||||||
|
python3 \
|
||||||
openssh-client
|
openssh-client
|
||||||
|
|
||||||
RUN curl -sSL -o /terraform.zip "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" \
|
RUN curl -sSL -o /terraform.zip "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" \
|
||||||
|
|
|
@ -35,16 +35,11 @@ source_tfvars /tmp/env
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
export AR_FLAGS=cr
|
export AR_FLAGS=cr
|
||||||
|
|
||||||
apt -q=3 update
|
apt update
|
||||||
|
apt dist-upgrade --yes
|
||||||
|
apt update
|
||||||
|
|
||||||
apt -q=3 dist-upgrade --yes
|
apt install \
|
||||||
|
|
||||||
add-apt-repository universe --yes
|
|
||||||
add-apt-repository multiverse --yes
|
|
||||||
|
|
||||||
apt -q=3 update
|
|
||||||
|
|
||||||
apt -q=3 install \
|
|
||||||
apt-transport-https \
|
apt-transport-https \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
curl \
|
curl \
|
||||||
|
@ -59,21 +54,15 @@ add-apt-repository \
|
||||||
$(lsb_release -cs) \
|
$(lsb_release -cs) \
|
||||||
stable" --yes
|
stable" --yes
|
||||||
|
|
||||||
apt -q=3 update
|
apt update
|
||||||
|
|
||||||
apt -q=3 install docker-ce --yes
|
apt install docker-ce --yes
|
||||||
|
|
||||||
export DOCKER_CLI_EXPERIMENTAL=enabled
|
export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||||
|
|
||||||
echo ${docker_password} | docker login -u ${docker_username} --password-stdin quay.io
|
echo ${docker_password} | docker login -u ${docker_username} --password-stdin quay.io
|
||||||
|
|
||||||
curl -sL -o /usr/local/bin/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme
|
|
||||||
chmod +x /usr/local/bin/gimme
|
|
||||||
|
|
||||||
eval "$(gimme 1.14.3)"
|
|
||||||
|
|
||||||
git clone https://github.com/kubernetes/ingress-nginx
|
git clone https://github.com/kubernetes/ingress-nginx
|
||||||
|
|
||||||
cd ingress-nginx/images/nginx
|
cd ingress-nginx/images/nginx
|
||||||
|
|
||||||
export TAG=$(git rev-parse HEAD)
|
export TAG=$(git rev-parse HEAD)
|
||||||
|
@ -82,4 +71,4 @@ make init-docker-buildx
|
||||||
docker buildx use ingress-nginx --default --global
|
docker buildx use ingress-nginx --default --global
|
||||||
|
|
||||||
echo "Building NGINX images..."
|
echo "Building NGINX images..."
|
||||||
make release
|
make container
|
|
@ -35,8 +35,14 @@ trap 'catch $? $LINENO' ERR
|
||||||
|
|
||||||
terraform init
|
terraform init
|
||||||
|
|
||||||
|
GET_UNTIL_VALID="
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
two_hours_from_now = datetime.utcnow() + timedelta(hours=2)
|
||||||
|
print(two_hours_from_now.strftime('%Y-%m-%dT%H:%M:%SZ'))
|
||||||
|
"
|
||||||
|
|
||||||
# destroy spot instance after two hours
|
# destroy spot instance after two hours
|
||||||
EC2_VALID_UNTIL=$(date -d "+2 hours" +%Y-%m-%dT%H:%M:%SZ)
|
EC2_VALID_UNTIL=$(python3 -c "$GET_UNTIL_VALID")
|
||||||
|
|
||||||
terraform plan \
|
terraform plan \
|
||||||
-var-file /root/aws.tfvars \
|
-var-file /root/aws.tfvars \
|
||||||
|
|
|
@ -165,8 +165,8 @@ resource "aws_spot_instance_request" "build_worker" {
|
||||||
}
|
}
|
||||||
|
|
||||||
provisioner "file" {
|
provisioner "file" {
|
||||||
source = "build-nginx.sh"
|
source = "build.sh"
|
||||||
destination = "/tmp/build-nginx.sh"
|
destination = "/tmp/build.sh"
|
||||||
}
|
}
|
||||||
|
|
||||||
provisioner "file" {
|
provisioner "file" {
|
||||||
|
@ -177,8 +177,8 @@ resource "aws_spot_instance_request" "build_worker" {
|
||||||
provisioner "remote-exec" {
|
provisioner "remote-exec" {
|
||||||
inline = [
|
inline = [
|
||||||
"echo Building nginx images...",
|
"echo Building nginx images...",
|
||||||
"chmod +x /tmp/build-nginx.sh",
|
"chmod +x /tmp/build.sh",
|
||||||
"sudo /tmp/build-nginx.sh",
|
"sudo /tmp/build.sh",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ variable "ssh_public_key_path" {
|
||||||
|
|
||||||
variable "instance_type" {
|
variable "instance_type" {
|
||||||
description = "EC2 instance"
|
description = "EC2 instance"
|
||||||
default = "c5.18xlarge"
|
default = "c5.24xlarge"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "project_tag" {
|
variable "project_tag" {
|
||||||
|
|
Loading…
Reference in a new issue