Skip to content

Commit 5f57a61

Browse files
authored
Merge pull request #12 from paraskuk/dev
add variables in TF
2 parents 6eac8d3 + 47ffa24 commit 5f57a61

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ The following implementations are provided:
6969
```sh
7070
docker login --username ${DOCKER_USERNAME}
7171
docker build -t fibonacci_rust:latest .
72-
docker tag fibonacci_rust:latest ${DOCKER_USERNAME}/fibonacci_rust:v24
73-
docker push ${DOCKER_USERNAME}/fibonacci_rust:v24
72+
docker tag fibonacci_rust:latest ${DOCKER_USERNAME}/fibonacci_rust:${DOCKER_TAG}
73+
docker push ${DOCKER_USERNAME}/fibonacci_rust:${DOCKER_TAG}
7474
```
7575

7676
## 1. Deploying the Application to Kubernetes via Terraform
@@ -90,7 +90,7 @@ terraform validate
9090
```
9191

9292
```sh
93-
terraform apply
93+
terraform apply -var="docker_username=your_docker_username" -var="docker_image_tag=your_docker_image_tag"
9494
```
9595

9696
- Once all resources are deployed you can start the minikube service to access the application.
@@ -133,7 +133,7 @@ imagePullSecrets:
133133
> [!TIP]
134134
> Navigate to the fibonacci/ directory and install the Helm chart for the first time:
135135
```sh
136-
helm install fibonacci .
136+
helm install fibonacci . --set image.repository=${DOCKER_USERNAME}/fibonacci_rust --set image.tag=${DOCKER_TAG}
137137
```
138138
> [!WARNING]
139139
> Do not execute helm install again as it will overwrite the existing deployment.
@@ -142,7 +142,7 @@ helm install fibonacci .
142142
> If you already have the chart installed and want to upgrade it:
143143
144144
```sh
145-
helm upgrade --install fibonacci .
145+
helm upgrade --install fibonacci . --set image.repository=${DOCKER_USERNAME}/fibonacci_rust --set image.tag=${DOCKER_TAG}
146146
```
147147
> [!TIP]
148148
> Check the deployment status:

fibonacci/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
replicaCount: 1
22

33
image:
4-
repository: paraskevas68/fibonacci_rust
5-
tag: v56
4+
repository: "${DOCKER_USERNAME}/fibonacci_rust"
5+
tag: "${DOCKER_TAG}"
66

77
pullPolicy: IfNotPresent
88

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ resource "kubernetes_deployment" "fibonacci" {
106106

107107
container {
108108
name = "fibonacci"
109-
image = "paraskevas68/fibonacci_rust:v56"
109+
image = "${var.docker_username}/fibonacci_rust:${var.docker_image_tag}"
110110

111111
resources {
112112
limits = {

variables.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
variable "docker_username" {
2+
description = "Docker username for pulling images"
3+
type = string
4+
}
5+
6+
variable "docker_image_tag" {
7+
description = "Docker image tag for pulling images"
8+
type = string
9+
}

0 commit comments

Comments
 (0)