зеркало из https://github.com/microsoft/bedrock.git
Add git-label variable to terraform template for flux (#851)
This commit is contained in:
Родитель
f4d2cbacf1
Коммит
efeb5e7063
|
@ -31,6 +31,7 @@ module "flux" {
|
||||||
gitops_ssh_key = "${var.gitops_ssh_key}"
|
gitops_ssh_key = "${var.gitops_ssh_key}"
|
||||||
gitops_path = "${var.gitops_path}"
|
gitops_path = "${var.gitops_path}"
|
||||||
gitops_poll_interval = "${var.gitops_poll_interval}"
|
gitops_poll_interval = "${var.gitops_poll_interval}"
|
||||||
|
gitops_label = "${var.gitops_label}"
|
||||||
gitops_url_branch = "${var.gitops_url_branch}"
|
gitops_url_branch = "${var.gitops_url_branch}"
|
||||||
enable_flux = "${var.enable_flux}"
|
enable_flux = "${var.enable_flux}"
|
||||||
flux_recreate = "${var.flux_recreate}"
|
flux_recreate = "${var.flux_recreate}"
|
||||||
|
|
|
@ -50,6 +50,11 @@ variable "gitops_poll_interval" {
|
||||||
default = "5m"
|
default = "5m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "gitops_label" {
|
||||||
|
type = "string"
|
||||||
|
default = "flux-sync"
|
||||||
|
}
|
||||||
|
|
||||||
variable "gitops_url_branch" {
|
variable "gitops_url_branch" {
|
||||||
type = "string"
|
type = "string"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
while getopts :b:f:g:k:d:e:c:s:r:t:z: option
|
while getopts :b:f:g:k:d:e:c:l:s:r:t:z: option
|
||||||
do
|
do
|
||||||
case "${option}" in
|
case "${option}" in
|
||||||
b) GITOPS_URL_BRANCH=${OPTARG};;
|
b) GITOPS_URL_BRANCH=${OPTARG};;
|
||||||
|
@ -9,6 +9,7 @@ do
|
||||||
d) REPO_ROOT_DIR=${OPTARG};;
|
d) REPO_ROOT_DIR=${OPTARG};;
|
||||||
e) GITOPS_PATH=${OPTARG};;
|
e) GITOPS_PATH=${OPTARG};;
|
||||||
c) GITOPS_POLL_INTERVAL=${OPTARG};;
|
c) GITOPS_POLL_INTERVAL=${OPTARG};;
|
||||||
|
l) GITOPS_LABEL=${OPTARG};;
|
||||||
s) ACR_ENABLED=${OPTARG};;
|
s) ACR_ENABLED=${OPTARG};;
|
||||||
r) FLUX_IMAGE_REPOSITORY=${OPTARG};;
|
r) FLUX_IMAGE_REPOSITORY=${OPTARG};;
|
||||||
t) FLUX_IMAGE_TAG=${OPTARG};;
|
t) FLUX_IMAGE_TAG=${OPTARG};;
|
||||||
|
@ -58,7 +59,7 @@ fi
|
||||||
# git url: where flux monitors for manifests
|
# git url: where flux monitors for manifests
|
||||||
# git ssh secret: kubernetes secret object for flux to read/write access to manifests repo
|
# git ssh secret: kubernetes secret object for flux to read/write access to manifests repo
|
||||||
echo "generating flux manifests with helm template"
|
echo "generating flux manifests with helm template"
|
||||||
if ! helm template . --name "$RELEASE_NAME" --namespace "$KUBE_NAMESPACE" --values values.yaml --set image.repository="$FLUX_IMAGE_REPOSITORY" --set image.tag="$FLUX_IMAGE_TAG" --output-dir "./$FLUX_MANIFESTS" --set git.url="$GITOPS_SSH_URL" --set git.branch="$GITOPS_URL_BRANCH" --set git.secretName="$KUBE_SECRET_NAME" --set git.path="$GITOPS_PATH" --set git.pollInterval="$GITOPS_POLL_INTERVAL" --set registry.acr.enabled="$ACR_ENABLED" --set syncGarbageCollection.enabled="$GC_ENABLED"; then
|
if ! helm template . --name "$RELEASE_NAME" --namespace "$KUBE_NAMESPACE" --values values.yaml --set image.repository="$FLUX_IMAGE_REPOSITORY" --set image.tag="$FLUX_IMAGE_TAG" --output-dir "./$FLUX_MANIFESTS" --set git.url="$GITOPS_SSH_URL" --set git.branch="$GITOPS_URL_BRANCH" --set git.secretName="$KUBE_SECRET_NAME" --set git.path="$GITOPS_PATH" --set git.pollInterval="$GITOPS_POLL_INTERVAL" --set git.label="$GITOPS_LABEL" --set registry.acr.enabled="$ACR_ENABLED" --set syncGarbageCollection.enabled="$GC_ENABLED"; then
|
||||||
echo "ERROR: failed to helm template"
|
echo "ERROR: failed to helm template"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -6,7 +6,7 @@ resource "null_resource" "deploy_flux" {
|
||||||
count = "${var.enable_flux ? 1 : 0}"
|
count = "${var.enable_flux ? 1 : 0}"
|
||||||
|
|
||||||
provisioner "local-exec" {
|
provisioner "local-exec" {
|
||||||
command = "echo 'Need to use this var so terraform waits for kubeconfig ' ${var.kubeconfig_complete};KUBECONFIG=${var.output_directory}/${var.kubeconfig_filename} ${path.module}/deploy_flux.sh -b '${var.gitops_url_branch}' -f '${var.flux_repo_url}' -g '${var.gitops_ssh_url}' -k '${var.gitops_ssh_key}' -d '${var.flux_clone_dir}' -c '${var.gitops_poll_interval}' -e '${var.gitops_path}' -s '${var.acr_enabled}' -r '${var.flux_image_repository}' -t '${var.flux_image_tag}' -z '${var.gc_enabled}'"
|
command = "echo 'Need to use this var so terraform waits for kubeconfig ' ${var.kubeconfig_complete};KUBECONFIG=${var.output_directory}/${var.kubeconfig_filename} ${path.module}/deploy_flux.sh -b '${var.gitops_url_branch}' -f '${var.flux_repo_url}' -g '${var.gitops_ssh_url}' -k '${var.gitops_ssh_key}' -d '${var.flux_clone_dir}' -c '${var.gitops_poll_interval}' -l '${var.gitops_label}' -e '${var.gitops_path}' -s '${var.acr_enabled}' -r '${var.flux_image_repository}' -t '${var.flux_image_tag}' -z '${var.gc_enabled}'"
|
||||||
}
|
}
|
||||||
|
|
||||||
triggers = {
|
triggers = {
|
||||||
|
|
|
@ -25,6 +25,11 @@ variable "gitops_poll_interval" {
|
||||||
default = "5m"
|
default = "5m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "gitops_label" {
|
||||||
|
type = "string"
|
||||||
|
default = "flux-sync"
|
||||||
|
}
|
||||||
|
|
||||||
variable "gitops_ssh_url" {
|
variable "gitops_ssh_url" {
|
||||||
description = "ssh git clone repository URL with Kubernetes manifests including services which runs in the cluster. Flux monitors this repo for Kubernetes manifest additions/changes preriodiaclly and apply them in the cluster."
|
description = "ssh git clone repository URL with Kubernetes manifests including services which runs in the cluster. Flux monitors this repo for Kubernetes manifest additions/changes preriodiaclly and apply them in the cluster."
|
||||||
type = "string"
|
type = "string"
|
||||||
|
|
|
@ -58,6 +58,7 @@ module "central_flux" {
|
||||||
flux_clone_dir = "${local.central_flux_clone_dir}"
|
flux_clone_dir = "${local.central_flux_clone_dir}"
|
||||||
gitops_path = "${var.gitops_central_path}"
|
gitops_path = "${var.gitops_central_path}"
|
||||||
gitops_poll_interval = "${var.gitops_poll_interval}"
|
gitops_poll_interval = "${var.gitops_poll_interval}"
|
||||||
|
gitops_label = "${var.gitops_label}"
|
||||||
}
|
}
|
||||||
|
|
||||||
module "central_tm_endpoint" {
|
module "central_tm_endpoint" {
|
||||||
|
|
|
@ -58,6 +58,7 @@ module "east_flux" {
|
||||||
flux_clone_dir = "${local.east_flux_clone_dir}"
|
flux_clone_dir = "${local.east_flux_clone_dir}"
|
||||||
gitops_path = "${var.gitops_east_path}"
|
gitops_path = "${var.gitops_east_path}"
|
||||||
gitops_poll_interval = "${var.gitops_poll_interval}"
|
gitops_poll_interval = "${var.gitops_poll_interval}"
|
||||||
|
gitops_label = "${var.gitops_label}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# # create a dynamic public ip and associate with traffic manger endpoint
|
# # create a dynamic public ip and associate with traffic manger endpoint
|
||||||
|
|
|
@ -36,6 +36,11 @@ variable "gitops_poll_interval" {
|
||||||
type = "string"
|
type = "string"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "gitops_label" {
|
||||||
|
type = "string"
|
||||||
|
default = "flux-sync"
|
||||||
|
}
|
||||||
|
|
||||||
variable "gitops_ssh_key" {
|
variable "gitops_ssh_key" {
|
||||||
type = "string"
|
type = "string"
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ module "west_flux" {
|
||||||
flux_clone_dir = "${local.west_flux_clone_dir}"
|
flux_clone_dir = "${local.west_flux_clone_dir}"
|
||||||
gitops_path = "${var.gitops_west_path}"
|
gitops_path = "${var.gitops_west_path}"
|
||||||
gitops_poll_interval = "${var.gitops_poll_interval}"
|
gitops_poll_interval = "${var.gitops_poll_interval}"
|
||||||
|
gitops_label = "${var.gitops_label}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# create a dynamic public ip and associate with traffic manger endpoint
|
# create a dynamic public ip and associate with traffic manger endpoint
|
||||||
|
|
|
@ -79,6 +79,7 @@ func TestIT_Bedrock_AzureMC_APIM_Test(t *testing.T) {
|
||||||
"gitops_ssh_url": "git@github.com:timfpark/fabrikate-cloud-native-manifests.git",
|
"gitops_ssh_url": "git@github.com:timfpark/fabrikate-cloud-native-manifests.git",
|
||||||
"gitops_ssh_key": sshkey,
|
"gitops_ssh_key": sshkey,
|
||||||
"gitops_poll_interval": "5m",
|
"gitops_poll_interval": "5m",
|
||||||
|
"gitops_label": "flux-sync"
|
||||||
|
|
||||||
"traffic_manager_profile_name": tmName,
|
"traffic_manager_profile_name": tmName,
|
||||||
"traffic_manager_dns_name": tm_dnsprefix,
|
"traffic_manager_dns_name": tm_dnsprefix,
|
||||||
|
|
|
@ -42,6 +42,7 @@ module "central_aks_gitops" {
|
||||||
gitops_path = "${var.gitops_central_path}"
|
gitops_path = "${var.gitops_central_path}"
|
||||||
gitops_url_branch = "${var.gitops_central_url_branch}"
|
gitops_url_branch = "${var.gitops_central_url_branch}"
|
||||||
gitops_poll_interval = "${var.gitops_poll_interval}"
|
gitops_poll_interval = "${var.gitops_poll_interval}"
|
||||||
|
gitops_label = "${var.gitops_label}"
|
||||||
resource_group_name = "${local.central_rg_name}"
|
resource_group_name = "${local.central_rg_name}"
|
||||||
service_cidr = "${var.central_service_cidr}"
|
service_cidr = "${var.central_service_cidr}"
|
||||||
service_principal_id = "${var.service_principal_id}"
|
service_principal_id = "${var.service_principal_id}"
|
||||||
|
|
|
@ -42,6 +42,7 @@ module "east_aks_gitops" {
|
||||||
gitops_path = "${var.gitops_east_path}"
|
gitops_path = "${var.gitops_east_path}"
|
||||||
gitops_url_branch = "${var.gitops_east_url_branch}"
|
gitops_url_branch = "${var.gitops_east_url_branch}"
|
||||||
gitops_poll_interval = "${var.gitops_poll_interval}"
|
gitops_poll_interval = "${var.gitops_poll_interval}"
|
||||||
|
gitops_label = "${var.gitops_label}"
|
||||||
resource_group_name = "${local.east_rg_name}"
|
resource_group_name = "${local.east_rg_name}"
|
||||||
service_cidr = "${var.east_service_cidr}"
|
service_cidr = "${var.east_service_cidr}"
|
||||||
service_principal_id = "${var.service_principal_id}"
|
service_principal_id = "${var.service_principal_id}"
|
||||||
|
|
|
@ -36,6 +36,11 @@ variable "gitops_poll_interval" {
|
||||||
default = "5m"
|
default = "5m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "gitops_label" {
|
||||||
|
type = "string"
|
||||||
|
default = "flux-sync"
|
||||||
|
}
|
||||||
|
|
||||||
variable "gitops_ssh_key" {
|
variable "gitops_ssh_key" {
|
||||||
type = "string"
|
type = "string"
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ module "west_aks_gitops" {
|
||||||
gitops_path = "${var.gitops_west_path}"
|
gitops_path = "${var.gitops_west_path}"
|
||||||
gitops_url_branch = "${var.gitops_west_url_branch}"
|
gitops_url_branch = "${var.gitops_west_url_branch}"
|
||||||
gitops_poll_interval = "${var.gitops_poll_interval}"
|
gitops_poll_interval = "${var.gitops_poll_interval}"
|
||||||
|
gitops_label = "${var.gitops_label}"
|
||||||
resource_group_name = "${local.west_rg_name}"
|
resource_group_name = "${local.west_rg_name}"
|
||||||
service_cidr = "${var.west_service_cidr}"
|
service_cidr = "${var.west_service_cidr}"
|
||||||
service_principal_id = "${var.service_principal_id}"
|
service_principal_id = "${var.service_principal_id}"
|
||||||
|
|
|
@ -35,6 +35,7 @@ module "aks-gitops" {
|
||||||
gitops_ssh_key = "${var.gitops_ssh_key}"
|
gitops_ssh_key = "${var.gitops_ssh_key}"
|
||||||
gitops_path = "${var.gitops_path}"
|
gitops_path = "${var.gitops_path}"
|
||||||
gitops_poll_interval = "${var.gitops_poll_interval}"
|
gitops_poll_interval = "${var.gitops_poll_interval}"
|
||||||
|
gitops_label = "${var.gitops_label}"
|
||||||
gitops_url_branch = "${var.gitops_url_branch}"
|
gitops_url_branch = "${var.gitops_url_branch}"
|
||||||
ssh_public_key = "${var.ssh_public_key}"
|
ssh_public_key = "${var.ssh_public_key}"
|
||||||
resource_group_name = "${data.azurerm_resource_group.cluster_rg.name}"
|
resource_group_name = "${data.azurerm_resource_group.cluster_rg.name}"
|
||||||
|
|
|
@ -17,3 +17,4 @@ vnet_name = "<vnet name>"
|
||||||
# gitops_path = "prod"
|
# gitops_path = "prod"
|
||||||
# network_policy = "calico"
|
# network_policy = "calico"
|
||||||
# oms_agent_enabled = "false"
|
# oms_agent_enabled = "false"
|
||||||
|
# gitops_label = "custom-flux-sync"
|
||||||
|
|
|
@ -77,6 +77,11 @@ variable "gitops_poll_interval" {
|
||||||
default = "5m"
|
default = "5m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "gitops_label" {
|
||||||
|
type = "string"
|
||||||
|
default = "flux-sync"
|
||||||
|
}
|
||||||
|
|
||||||
variable "vnet_name" {
|
variable "vnet_name" {
|
||||||
type = "string"
|
type = "string"
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@ service_principal_secret = "<service principal secret>"
|
||||||
# gitops_url_branch = "release-123"
|
# gitops_url_branch = "release-123"
|
||||||
# gitops_poll_interval = "30s"
|
# gitops_poll_interval = "30s"
|
||||||
# gitops_path = "prod"
|
# gitops_path = "prod"
|
||||||
|
# gitops_label = "custom-flux-sync"
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ module "aks-gitops" {
|
||||||
gitops_ssh_key = "${var.gitops_ssh_key}"
|
gitops_ssh_key = "${var.gitops_ssh_key}"
|
||||||
gitops_path = "${var.gitops_path}"
|
gitops_path = "${var.gitops_path}"
|
||||||
gitops_poll_interval = "${var.gitops_poll_interval}"
|
gitops_poll_interval = "${var.gitops_poll_interval}"
|
||||||
|
gitops_label = "${var.gitops_label}"
|
||||||
gitops_url_branch = "${var.gitops_url_branch}"
|
gitops_url_branch = "${var.gitops_url_branch}"
|
||||||
resource_group_name = "${data.azurerm_resource_group.cluster_rg.name}"
|
resource_group_name = "${data.azurerm_resource_group.cluster_rg.name}"
|
||||||
service_principal_id = "${var.service_principal_id}"
|
service_principal_id = "${var.service_principal_id}"
|
||||||
|
|
|
@ -40,6 +40,11 @@ variable "gitops_poll_interval" {
|
||||||
default = "5m"
|
default = "5m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "gitops_label" {
|
||||||
|
type = "string"
|
||||||
|
default = "flux-sync"
|
||||||
|
}
|
||||||
|
|
||||||
variable "gitops_ssh_url" {
|
variable "gitops_ssh_url" {
|
||||||
type = "string"
|
type = "string"
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,8 @@ tenant_id = "<tenantId>"
|
||||||
# gitops_poll_interval = "30s"
|
# gitops_poll_interval = "30s"
|
||||||
|
|
||||||
# gitops_path = "prod"
|
# gitops_path = "prod"
|
||||||
|
|
||||||
|
# gitops_label = "custom-flux-sync"
|
||||||
```
|
```
|
||||||
|
|
||||||
To deploy the azure-single-keyvault environment, run the following commands in your environment directory:
|
To deploy the azure-single-keyvault environment, run the following commands in your environment directory:
|
||||||
|
|
|
@ -33,6 +33,7 @@ module "aks-gitops" {
|
||||||
gitops_ssh_key = "${var.gitops_ssh_key}"
|
gitops_ssh_key = "${var.gitops_ssh_key}"
|
||||||
gitops_path = "${var.gitops_path}"
|
gitops_path = "${var.gitops_path}"
|
||||||
gitops_poll_interval = "${var.gitops_poll_interval}"
|
gitops_poll_interval = "${var.gitops_poll_interval}"
|
||||||
|
gitops_label = "${var.gitops_label}"
|
||||||
gitops_url_branch = "${var.gitops_url_branch}"
|
gitops_url_branch = "${var.gitops_url_branch}"
|
||||||
resource_group_name = "${data.azurerm_resource_group.cluster_rg.name}"
|
resource_group_name = "${data.azurerm_resource_group.cluster_rg.name}"
|
||||||
service_principal_id = "${var.service_principal_id}"
|
service_principal_id = "${var.service_principal_id}"
|
||||||
|
|
|
@ -45,6 +45,11 @@ variable "gitops_poll_interval" {
|
||||||
default = "5m"
|
default = "5m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "gitops_label" {
|
||||||
|
type = "string"
|
||||||
|
default = "flux-sync"
|
||||||
|
}
|
||||||
|
|
||||||
variable "gitops_ssh_url" {
|
variable "gitops_ssh_url" {
|
||||||
type = "string"
|
type = "string"
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,11 @@ variable "gitops_poll_interval" {
|
||||||
default = "5m"
|
default = "5m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "gitops_label" {
|
||||||
|
type = "string"
|
||||||
|
default = "flux-sync"
|
||||||
|
}
|
||||||
|
|
||||||
variable "gitops_ssh_url" {
|
variable "gitops_ssh_url" {
|
||||||
type = "string"
|
type = "string"
|
||||||
}
|
}
|
||||||
|
|
|
@ -277,6 +277,7 @@ vnet_name = "<vnet name>"
|
||||||
#--------------------------------------------------------------
|
#--------------------------------------------------------------
|
||||||
# gitops_url_branch = "release-123"
|
# gitops_url_branch = "release-123"
|
||||||
# gitops_poll_interval = "30s"
|
# gitops_poll_interval = "30s"
|
||||||
|
# gitops_label = "custom-flux-sync"
|
||||||
# gitops_path = "prod"
|
# gitops_path = "prod"
|
||||||
# network_policy = "calico"
|
# network_policy = "calico"
|
||||||
# network_plugin = "azure"
|
# network_plugin = "azure"
|
||||||
|
|
|
@ -183,6 +183,7 @@ func TestIT_Bedrock_AzureMC_Test(t *testing.T) {
|
||||||
"gitops_ssh_url": "git@github.com:timfpark/fabrikate-cloud-native-manifests.git",
|
"gitops_ssh_url": "git@github.com:timfpark/fabrikate-cloud-native-manifests.git",
|
||||||
"gitops_ssh_key": sshkey,
|
"gitops_ssh_key": sshkey,
|
||||||
"gitops_poll_interval": "5m",
|
"gitops_poll_interval": "5m",
|
||||||
|
"gitops_label": "flux-sync",
|
||||||
"keyvault_name": kvName,
|
"keyvault_name": kvName,
|
||||||
"keyvault_resource_group": kvRG,
|
"keyvault_resource_group": kvRG,
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче