Skip to content

Commit 21894c1

Browse files
Merge pull request #64 from pagopa/PIDM-487
chore: deploy with wl identity
2 parents 1d37aa0 + c5c9fd2 commit 21894c1

File tree

12 files changed

+85
-112
lines changed

12 files changed

+85
-112
lines changed

.github/workflows/deploy_with_github_runner.yml

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
required: true
88
description: The name of the environment where to deploy
99
type: string
10+
branch:
11+
required: false
12+
default: ${{ github.ref_name }}
13+
type: string
1014

1115
env:
1216
APP_NAME: apiconfig-selfcare-integration
@@ -17,37 +21,15 @@ permissions:
1721
contents: read
1822

1923
jobs:
20-
create_runner:
21-
name: Create Runner
22-
runs-on: ubuntu-22.04
23-
environment:
24-
name: ${{ inputs.environment }}
25-
outputs:
26-
runner_name: ${{ steps.create_github_runner.outputs.runner_name }}
27-
steps:
28-
- name: Create GitHub Runner
29-
id: create_github_runner
30-
# from https://github.com/pagopa/eng-github-actions-iac-template/tree/main/azure/github-self-hosted-runner-azure-create-action
31-
uses: pagopa/eng-github-actions-iac-template/azure/github-self-hosted-runner-azure-create-action@main
32-
with:
33-
client_id: ${{ secrets.CLIENT_ID }}
34-
tenant_id: ${{ secrets.TENANT_ID }}
35-
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
36-
container_app_environment_name: ${{ vars.CONTAINER_APP_ENVIRONMENT_NAME }}
37-
resource_group_name: ${{ vars.CONTAINER_APP_ENVIRONMENT_RESOURCE_GROUP_NAME }} # RG of the runner
38-
pat_token: ${{ secrets.BOT_TOKEN_GITHUB }}
39-
self_hosted_runner_image_tag: "latest"
40-
4124
deploy:
42-
needs: [ create_runner ]
43-
runs-on: [ self-hosted, "${{ needs.create_runner.outputs.runner_name }}" ]
25+
runs-on: [ self-hosted-job, "${{ inputs.environment }}" ]
4426
name: Deploy on AKS
4527
environment: ${{ inputs.environment }}
4628
steps:
4729
- name: Deploy
4830
uses: pagopa/github-actions-template/aks-deploy@main
4931
with:
50-
branch: ${{ github.ref_name }}
32+
branch: ${{ inputs.branch }}
5133
client_id: ${{ secrets.CLIENT_ID }}
5234
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
5335
tenant_id: ${{ secrets.TENANT_ID }}
@@ -56,27 +38,8 @@ jobs:
5638
cluster_name: ${{ vars.CLUSTER_NAME }}
5739
resource_group: ${{ vars.CLUSTER_RESOURCE_GROUP }}
5840
app_name: ${{ env.APP_NAME }}
59-
helm_upgrade_options: "--debug"
60-
timeout: "10m0s"
61-
62-
cleanup_runner:
63-
name: Cleanup Runner
64-
needs: [ create_runner, deploy ]
65-
if: ${{ success() || failure() }}
66-
runs-on: ubuntu-22.04
67-
environment: ${{ inputs.environment }}
68-
steps:
69-
- name: Cleanup GitHub Runner
70-
id: cleanup_github_runner
71-
# from https://github.com/pagopa/eng-github-actions-iac-template/tree/main/azure/github-self-hosted-runner-azure-cleanup-action
72-
uses: pagopa/eng-github-actions-iac-template/azure/github-self-hosted-runner-azure-cleanup-action@0ee2f58fd46d10ac7f00bce4304b98db3dbdbe9a
73-
with:
74-
client_id: ${{ secrets.CLIENT_ID }}
75-
tenant_id: ${{ secrets.TENANT_ID }}
76-
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
77-
resource_group_name: ${{ vars.CONTAINER_APP_ENVIRONMENT_RESOURCE_GROUP_NAME }}
78-
runner_name: ${{ needs.create_runner.outputs.runner_name }}
79-
pat_token: ${{ secrets.BOT_TOKEN_GITHUB }}
41+
helm_upgrade_options: "--debug --set microservice-chart.azure.workloadIdentityClientId=${{vars.WORKLOAD_IDENTITY_ID}} --set postgresql.azure.workloadIdentityClientId=${{vars.WORKLOAD_IDENTITY_ID}}"
42+
timeout: "15m0s"
8043

8144
update_openapi:
8245
needs: [ deploy ]

.github/workflows/release_deploy.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Release And Deploy
33
# Controls when the workflow will run
44
on:
55
pull_request:
6+
branches:
7+
- main
68
types: [ closed ]
79

810
# Allows you to run this workflow manually from the Actions tab
@@ -21,7 +23,7 @@ on:
2123
type: choice
2224
description: Select the version
2325
options:
24-
- ''
26+
- patch
2527
- skip_or_promote
2628
- new_release
2729
- breaking_change

.identity/.terraform.lock.hcl

Lines changed: 41 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.identity/00_data.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,13 @@ data "azurerm_key_vault_secret" "key_vault_read_package_token" {
5656
key_vault_id = data.azurerm_key_vault.key_vault.id
5757
}
5858

59+
data "azurerm_user_assigned_identity" "workload_identity_clientid" {
60+
name = "apiconfig-workload-identity"
61+
resource_group_name = "pagopa-${var.env_short}-${local.location_short}-${var.env}-aks-rg"
62+
}
63+
64+
data "azurerm_user_assigned_identity" "identity_cd_01" {
65+
resource_group_name = "${local.product}-identity-rg"
66+
name = "${local.product}-${local.domain}-job-01-github-cd-identity"
67+
}
68+

.identity/03_github_environment.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ resource "github_repository_environment" "github_repository_environment" {
2121

2222
locals {
2323
env_secrets = {
24-
"CLIENT_ID" : module.github_runner_app.application_id,
24+
"CLIENT_ID" : data.azurerm_user_assigned_identity.identity_cd_01.client_id,
2525
"TENANT_ID" : data.azurerm_client_config.current.tenant_id,
2626
"SUBSCRIPTION_ID" : data.azurerm_subscription.current.subscription_id,
2727
}
@@ -32,6 +32,7 @@ locals {
3232
"CLUSTER_RESOURCE_GROUP" : local.aks_cluster.resource_group_name,
3333
"DOMAIN" : local.domain,
3434
"NAMESPACE" : local.domain,
35+
"WORKLOAD_IDENTITY_ID": data.azurerm_user_assigned_identity.workload_identity_clientid.client_id
3536
}
3637
}
3738

.identity/99_main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ terraform {
44
required_providers {
55
azuread = {
66
source = "hashicorp/azuread"
7-
version = "2.30.0"
7+
version = "~> 2.53"
88
}
99
azurerm = {
1010
source = "hashicorp/azurerm"
11-
version = "3.45.0"
11+
version = "~> 3.117"
1212
}
1313
github = {
1414
source = "integrations/github"

helm/Chart.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ apiVersion: v2
22
name: pagopa-api-config-selfcare-integration
33
description: Microservice that manages requests from selfcare
44
type: application
5-
version: 1.102.0
6-
appVersion: 1.12.5
5+
version: 1.103.0
6+
appVersion: 1.12.5-1-PIDM-487
77
dependencies:
88
- name: microservice-chart
9-
version: 2.8.0
9+
version: 7.5.0
1010
repository: "https://pagopa.github.io/aks-microservice-chart-blueprint"
1111
alias: postgresql
1212
condition: postgresql.enabled

helm/values-dev.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ microservice-chart: &microservice-chart
2727
envSecret: {}
2828
image:
2929
repository: ghcr.io/pagopa/pagopa-api-config-selfcare-integration
30-
tag: "1.12.5"
30+
tag: "1.12.5-1-PIDM-487"
3131
pullPolicy: Always
3232
livenessProbe:
3333
httpGet:
@@ -45,6 +45,7 @@ microservice-chart: &microservice-chart
4545
periodSeconds: 10
4646
deployment:
4747
create: true
48+
replicas: 1
4849
serviceMonitor:
4950
create: true
5051
endpoints:
@@ -64,9 +65,9 @@ microservice-chart: &microservice-chart
6465
host: "weudev.apiconfig.internal.dev.platform.pagopa.it"
6566
servicePort: 8080
6667
serviceAccount:
67-
create: false
68-
annotations: {}
69-
name: ""
68+
name: "apiconfig-workload-identity"
69+
azure:
70+
workloadIdentityClientId: <workload-identity-client-id-set-automatically-by-gha>
7071
podAnnotations: {}
7172
podSecurityContext:
7273
seccompProfile:

helm/values-prod.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ microservice-chart: &microservice-chart
2727
envSecret: {}
2828
image:
2929
repository: ghcr.io/pagopa/pagopa-api-config-selfcare-integration
30-
tag: "1.12.5"
30+
tag: "1.12.5-1-PIDM-487"
3131
pullPolicy: Always
3232
livenessProbe:
3333
httpGet:
@@ -64,9 +64,9 @@ microservice-chart: &microservice-chart
6464
host: "weuprod.apiconfig.internal.platform.pagopa.it"
6565
servicePort: 8080
6666
serviceAccount:
67-
create: false
68-
annotations: {}
69-
name: ""
67+
name: "apiconfig-workload-identity"
68+
azure:
69+
workloadIdentityClientId: <workload-identity-client-id-set-automatically-by-gha>
7070
podAnnotations: {}
7171
podSecurityContext:
7272
seccompProfile:

helm/values-uat.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ microservice-chart: &microservice-chart
2727
envSecret: {}
2828
image:
2929
repository: ghcr.io/pagopa/pagopa-api-config-selfcare-integration
30-
tag: "1.12.5"
30+
tag: "1.12.5-1-PIDM-487"
3131
pullPolicy: Always
3232
livenessProbe:
3333
httpGet:
@@ -45,6 +45,7 @@ microservice-chart: &microservice-chart
4545
periodSeconds: 10
4646
deployment:
4747
create: true
48+
replicas: 1
4849
serviceMonitor:
4950
create: true
5051
endpoints:
@@ -64,9 +65,9 @@ microservice-chart: &microservice-chart
6465
host: "weuuat.apiconfig.internal.uat.platform.pagopa.it"
6566
servicePort: 8080
6667
serviceAccount:
67-
create: false
68-
annotations: {}
69-
name: ""
68+
name: "apiconfig-workload-identity"
69+
azure:
70+
workloadIdentityClientId: <workload-identity-client-id-set-automatically-by-gha>
7071
podAnnotations: {}
7172
podSecurityContext:
7273
seccompProfile:

0 commit comments

Comments
 (0)