Add git-label variable to terraform template for flux (#851)

This commit is contained in:
Edaena Salinas 2019-12-16 11:03:46 -08:00 коммит произвёл GitHub
Родитель f4d2cbacf1
Коммит efeb5e7063
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
26 изменённых файлов: 61 добавлений и 3 удалений

Просмотреть файл

@ -31,6 +31,7 @@ module "flux" {
gitops_ssh_key = "${var.gitops_ssh_key}"
gitops_path = "${var.gitops_path}"
gitops_poll_interval = "${var.gitops_poll_interval}"
gitops_label = "${var.gitops_label}"
gitops_url_branch = "${var.gitops_url_branch}"
enable_flux = "${var.enable_flux}"
flux_recreate = "${var.flux_recreate}"

Просмотреть файл

@ -50,6 +50,11 @@ variable "gitops_poll_interval" {
default = "5m"
}
variable "gitops_label" {
type = "string"
default = "flux-sync"
}
variable "gitops_url_branch" {
type = "string"
}

Просмотреть файл

@ -1,5 +1,5 @@
#!/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
case "${option}" in
b) GITOPS_URL_BRANCH=${OPTARG};;
@ -9,6 +9,7 @@ do
d) REPO_ROOT_DIR=${OPTARG};;
e) GITOPS_PATH=${OPTARG};;
c) GITOPS_POLL_INTERVAL=${OPTARG};;
l) GITOPS_LABEL=${OPTARG};;
s) ACR_ENABLED=${OPTARG};;
r) FLUX_IMAGE_REPOSITORY=${OPTARG};;
t) FLUX_IMAGE_TAG=${OPTARG};;
@ -58,7 +59,7 @@ fi
# git url: where flux monitors for manifests
# git ssh secret: kubernetes secret object for flux to read/write access to manifests repo
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"
exit 1
fi

Просмотреть файл

@ -6,7 +6,7 @@ resource "null_resource" "deploy_flux" {
count = "${var.enable_flux ? 1 : 0}"
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 = {

Просмотреть файл

@ -25,6 +25,11 @@ variable "gitops_poll_interval" {
default = "5m"
}
variable "gitops_label" {
type = "string"
default = "flux-sync"
}
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."
type = "string"

Просмотреть файл

@ -58,6 +58,7 @@ module "central_flux" {
flux_clone_dir = "${local.central_flux_clone_dir}"
gitops_path = "${var.gitops_central_path}"
gitops_poll_interval = "${var.gitops_poll_interval}"
gitops_label = "${var.gitops_label}"
}
module "central_tm_endpoint" {

Просмотреть файл

@ -58,6 +58,7 @@ module "east_flux" {
flux_clone_dir = "${local.east_flux_clone_dir}"
gitops_path = "${var.gitops_east_path}"
gitops_poll_interval = "${var.gitops_poll_interval}"
gitops_label = "${var.gitops_label}"
}
# # create a dynamic public ip and associate with traffic manger endpoint

Просмотреть файл

@ -36,6 +36,11 @@ variable "gitops_poll_interval" {
type = "string"
}
variable "gitops_label" {
type = "string"
default = "flux-sync"
}
variable "gitops_ssh_key" {
type = "string"
}

Просмотреть файл

@ -58,6 +58,7 @@ module "west_flux" {
flux_clone_dir = "${local.west_flux_clone_dir}"
gitops_path = "${var.gitops_west_path}"
gitops_poll_interval = "${var.gitops_poll_interval}"
gitops_label = "${var.gitops_label}"
}
# 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_key": sshkey,
"gitops_poll_interval": "5m",
"gitops_label": "flux-sync"
"traffic_manager_profile_name": tmName,
"traffic_manager_dns_name": tm_dnsprefix,

Просмотреть файл

@ -42,6 +42,7 @@ module "central_aks_gitops" {
gitops_path = "${var.gitops_central_path}"
gitops_url_branch = "${var.gitops_central_url_branch}"
gitops_poll_interval = "${var.gitops_poll_interval}"
gitops_label = "${var.gitops_label}"
resource_group_name = "${local.central_rg_name}"
service_cidr = "${var.central_service_cidr}"
service_principal_id = "${var.service_principal_id}"

Просмотреть файл

@ -42,6 +42,7 @@ module "east_aks_gitops" {
gitops_path = "${var.gitops_east_path}"
gitops_url_branch = "${var.gitops_east_url_branch}"
gitops_poll_interval = "${var.gitops_poll_interval}"
gitops_label = "${var.gitops_label}"
resource_group_name = "${local.east_rg_name}"
service_cidr = "${var.east_service_cidr}"
service_principal_id = "${var.service_principal_id}"

Просмотреть файл

@ -36,6 +36,11 @@ variable "gitops_poll_interval" {
default = "5m"
}
variable "gitops_label" {
type = "string"
default = "flux-sync"
}
variable "gitops_ssh_key" {
type = "string"
}

Просмотреть файл

@ -42,6 +42,7 @@ module "west_aks_gitops" {
gitops_path = "${var.gitops_west_path}"
gitops_url_branch = "${var.gitops_west_url_branch}"
gitops_poll_interval = "${var.gitops_poll_interval}"
gitops_label = "${var.gitops_label}"
resource_group_name = "${local.west_rg_name}"
service_cidr = "${var.west_service_cidr}"
service_principal_id = "${var.service_principal_id}"

Просмотреть файл

@ -35,6 +35,7 @@ module "aks-gitops" {
gitops_ssh_key = "${var.gitops_ssh_key}"
gitops_path = "${var.gitops_path}"
gitops_poll_interval = "${var.gitops_poll_interval}"
gitops_label = "${var.gitops_label}"
gitops_url_branch = "${var.gitops_url_branch}"
ssh_public_key = "${var.ssh_public_key}"
resource_group_name = "${data.azurerm_resource_group.cluster_rg.name}"

Просмотреть файл

@ -17,3 +17,4 @@ vnet_name = "<vnet name>"
# gitops_path = "prod"
# network_policy = "calico"
# oms_agent_enabled = "false"
# gitops_label = "custom-flux-sync"

Просмотреть файл

@ -77,6 +77,11 @@ variable "gitops_poll_interval" {
default = "5m"
}
variable "gitops_label" {
type = "string"
default = "flux-sync"
}
variable "vnet_name" {
type = "string"
}

Просмотреть файл

@ -77,6 +77,7 @@ service_principal_secret = "<service principal secret>"
# gitops_url_branch = "release-123"
# gitops_poll_interval = "30s"
# gitops_path = "prod"
# gitops_label = "custom-flux-sync"
```

Просмотреть файл

@ -32,6 +32,7 @@ module "aks-gitops" {
gitops_ssh_key = "${var.gitops_ssh_key}"
gitops_path = "${var.gitops_path}"
gitops_poll_interval = "${var.gitops_poll_interval}"
gitops_label = "${var.gitops_label}"
gitops_url_branch = "${var.gitops_url_branch}"
resource_group_name = "${data.azurerm_resource_group.cluster_rg.name}"
service_principal_id = "${var.service_principal_id}"

Просмотреть файл

@ -40,6 +40,11 @@ variable "gitops_poll_interval" {
default = "5m"
}
variable "gitops_label" {
type = "string"
default = "flux-sync"
}
variable "gitops_ssh_url" {
type = "string"
}

Просмотреть файл

@ -91,6 +91,8 @@ tenant_id = "<tenantId>"
# gitops_poll_interval = "30s"
# gitops_path = "prod"
# gitops_label = "custom-flux-sync"
```
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_path = "${var.gitops_path}"
gitops_poll_interval = "${var.gitops_poll_interval}"
gitops_label = "${var.gitops_label}"
gitops_url_branch = "${var.gitops_url_branch}"
resource_group_name = "${data.azurerm_resource_group.cluster_rg.name}"
service_principal_id = "${var.service_principal_id}"

Просмотреть файл

@ -45,6 +45,11 @@ variable "gitops_poll_interval" {
default = "5m"
}
variable "gitops_label" {
type = "string"
default = "flux-sync"
}
variable "gitops_ssh_url" {
type = "string"
}

Просмотреть файл

@ -45,6 +45,11 @@ variable "gitops_poll_interval" {
default = "5m"
}
variable "gitops_label" {
type = "string"
default = "flux-sync"
}
variable "gitops_ssh_url" {
type = "string"
}

Просмотреть файл

@ -277,6 +277,7 @@ vnet_name = "<vnet name>"
#--------------------------------------------------------------
# gitops_url_branch = "release-123"
# gitops_poll_interval = "30s"
# gitops_label = "custom-flux-sync"
# gitops_path = "prod"
# network_policy = "calico"
# 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_key": sshkey,
"gitops_poll_interval": "5m",
"gitops_label": "flux-sync",
"keyvault_name": kvName,
"keyvault_resource_group": kvRG,