Skip to content

Commit 7f92ef6

Browse files
authored
Merge pull request #2828 from oracle-devrel/oke-gitops
oke-gitops update
2 parents b916ac3 + 11de8e2 commit 7f92ef6

30 files changed

Lines changed: 892 additions & 314 deletions

app-dev/devops-and-containers/oke/oke-gitops/flux-solution.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ Open the created OCI DevOps project and confirm:
5555
4. OKE environment exists and points to the expected cluster.
5656

5757
### 3. Run Mirror Build Pipeline
58+
Before running build pipeline `mirror-gitops-agent`, create these Kubernetes prerequisites in the target cluster:
59+
60+
1. Namespace `flux-system`.
61+
2. Image pull secret `ocirsecret` in namespace `flux-system` with OCIR credentials.
62+
63+
Example:
64+
65+
```bash
66+
kubectl create namespace flux-system
67+
kubectl create secret docker-registry ocirsecret \
68+
--namespace flux-system \
69+
--docker-server=<region-key>.ocir.io \
70+
--docker-username='<tenancy-namespace>/<identity-domain/<username>' \
71+
--docker-password='<auth-token>' \
72+
--docker-email='<email>'
73+
```
74+
5875
Run build pipeline `mirror-gitops-agent`:
5976

6077
1. Trigger pipeline run on `main`.
Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
11
module "devops" {
2-
source = "./modules/devops"
3-
compartment_id = var.devops_compartment_id # Both DevOps project and OCIR will be here
4-
region = var.region
5-
tenancy_id = var.tenancy_ocid
6-
create_notification_topic = var.create_notification_topic
7-
notification_topic_id = var.notification_topic_id
8-
notification_topic_name = var.notification_topic_name
9-
notification_topic_description = var.notification_topic_description
10-
devops_project_name = var.devops_project_name
11-
devops_project_description = var.devops_project_description
12-
devops_log_group_name = var.devops_log_group_name
13-
devops_log_group_description = var.devops_log_group_description
2+
source = "./modules/devops"
3+
compartment_id = var.devops_compartment_id # Both DevOps project and OCIR will be here
4+
region = var.region
5+
tenancy_id = var.tenancy_ocid
6+
create_notification_topic = var.create_notification_topic
7+
notification_topic_id = var.notification_topic_id
8+
notification_topic_name = var.notification_topic_name
9+
notification_topic_description = var.notification_topic_description
10+
devops_project_name = var.devops_project_name
11+
devops_project_description = var.devops_project_description
12+
devops_log_group_name = var.devops_log_group_name
13+
devops_log_group_description = var.devops_log_group_description
1414
devops_log_retention_period_in_days = var.devops_log_retention_period_in_days
15-
gitops_agent = var.gitops_agent
15+
gitops_agent = var.gitops_agent
1616

17-
git_username = local.git_username
18-
git_password = var.auth_token
17+
git_username = local.git_username
18+
git_password = var.auth_token
1919
ocir_repo_path_prefix = var.ocir_repo_path_prefix
20-
flux_agent_chart_version = var.flux_agent_chart_version
2120

2221
# OKE ENVIRONMENT
23-
oke_cluster_id = var.oke_cluster_id
24-
oke_environment_name = var.oke_environment_name
22+
oke_cluster_id = var.oke_cluster_id
23+
oke_environment_name = var.oke_environment_name
2524
oke_environment_description = var.oke_environment_description
26-
is_oke_cluster_private = var.is_oke_cluster_private
27-
oke_worker_subnet_id = var.oke_worker_subnet_id
28-
oke_worker_nsg_id = var.oke_worker_nsg_id
25+
is_oke_cluster_private = var.is_oke_cluster_private
26+
oke_worker_subnet_id = var.oke_worker_subnet_id
27+
oke_worker_nsg_id = var.oke_worker_nsg_id
2928
}
3029

3130
module "iam" {
32-
source = "./modules/iam"
33-
tenancy_id = var.tenancy_ocid
34-
compartment_id = var.devops_compartment_id
31+
source = "./modules/iam"
32+
compartment_id = var.devops_compartment_id
33+
iam_domain_id = var.devops_iam_domain_id
34+
kms_compartment_id = var.kms_compartment_id
3535
network_compartment_id = var.network_compartment_id
36-
oke_compartment_id = var.oke_compartment_id
37-
devops_policy_name = var.devops_policy_name
38-
domain_name = var.identity_domain_name
39-
dynamic_group_name = var.devops_dynamic_group_name
36+
oke_compartment_id = var.oke_compartment_id
37+
devops_policy_name = var.devops_policy_name
38+
dynamic_group_name = var.devops_dynamic_group_name
4039
is_oke_cluster_private = var.is_oke_cluster_private
41-
count = var.create_iam ? 1 : 0
42-
providers = {oci = oci.home}
40+
count = var.create_iam ? 1 : 0
41+
providers = { oci = oci.home }
4342
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
resource oci_devops_deploy_artifact flux_operator_chart {
1+
resource "oci_devops_deploy_artifact" "flux_operator_chart" {
22
argument_substitution_mode = "NONE"
33
deploy_artifact_source {
4-
chart_url = "oci://${local.region_key}.ocir.io/${local.namespace}/${var.ocir_repo_path_prefix}/helm/flux-operator"
4+
chart_url = "oci://${local.region_key}.ocir.io/${local.namespace}/${var.ocir_repo_path_prefix}/charts/flux-operator"
55
deploy_artifact_source_type = "HELM_CHART"
66
deploy_artifact_version = "$${chart_version}"
77
helm_verification_key_source {
@@ -11,17 +11,17 @@ resource oci_devops_deploy_artifact flux_operator_chart {
1111
deploy_artifact_type = "HELM_CHART"
1212
description = "Location to the internal flux-operator chart generated by the build pipeline"
1313
display_name = "flux-operator-chart"
14-
project_id = oci_devops_project.devops_project.id
14+
project_id = oci_devops_project.devops_project.id
1515
}
1616

17-
resource oci_devops_deploy_artifact flux_operator_values {
17+
resource "oci_devops_deploy_artifact" "flux_operator_values" {
1818
argument_substitution_mode = "SUBSTITUTE_PLACEHOLDERS"
1919
deploy_artifact_source {
20-
base64encoded_content = filebase64("${path.root}/templates/flux-operator-values.yaml")
20+
base64encoded_content = filebase64("${path.root}/templates/flux-operator-values.yaml")
2121
deploy_artifact_source_type = "INLINE"
2222
}
2323
deploy_artifact_type = "GENERIC_FILE"
2424
description = "Values of the flux-operator Helm Chart"
2525
display_name = "flux-operator-chart-values"
26-
project_id = oci_devops_project.devops_project.id
26+
project_id = oci_devops_project.devops_project.id
2727
}
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
resource "oci_devops_build_pipeline" "mirror_gitops_agent" {
2-
project_id = oci_devops_project.devops_project.id
2+
project_id = oci_devops_project.devops_project.id
33
display_name = "mirror-gitops-agent"
4-
description = "Pipeline to mirror the public Helm Chart of the GitOps Agent into OCIR"
4+
description = "Pipeline to mirror the public Helm Chart of the GitOps Agent into OCIR"
55
}
66

77
resource "oci_devops_build_pipeline_stage" "mirror_gitops_agent_stage" {
@@ -15,17 +15,17 @@ resource "oci_devops_build_pipeline_stage" "mirror_gitops_agent_stage" {
1515
build_source_collection {
1616
items {
1717
connection_type = "DEVOPS_CODE_REPOSITORY"
18-
branch = "main"
19-
name = "pipelines"
20-
repository_id = oci_devops_repository.devops_pipelines_repo_flux.0.id
21-
repository_url = oci_devops_repository.devops_pipelines_repo_flux.0.http_url
18+
branch = "main"
19+
name = "pipelines"
20+
repository_id = oci_devops_repository.devops_pipelines_repo_flux.0.id
21+
repository_url = oci_devops_repository.devops_pipelines_repo_flux.0.http_url
2222
}
2323
}
24-
build_spec_file = "mirror_flux_operator.yaml"
25-
display_name = "Mirror GitOps Agent Helm Chart"
26-
description = "Stage to import a public Helm Chart into the tenancy Oracle Container Registry"
27-
primary_build_source = "pipelines"
28-
image = "OL8_X86_64_STANDARD_10"
24+
build_spec_file = "mirror_flux_operator.yaml"
25+
display_name = "Mirror GitOps Agent Helm Chart"
26+
description = "Stage to import a public Helm Chart into the tenancy Oracle Container Registry"
27+
primary_build_source = "pipelines"
28+
image = "OL8_X86_64_STANDARD_10"
2929
stage_execution_timeout_in_seconds = 36000
3030
}
3131

@@ -37,8 +37,8 @@ resource "oci_devops_build_pipeline_stage" "trigger_helm_deploy" {
3737
id = oci_devops_build_pipeline_stage.mirror_gitops_agent_stage.id
3838
}
3939
}
40-
deploy_pipeline_id = oci_devops_deploy_pipeline.deploy_pipeline_helm.id
41-
description = "Trigger CD pipeline to deploy on OKE"
42-
display_name = "Trigger Helm Deployment pipeline"
40+
deploy_pipeline_id = oci_devops_deploy_pipeline.deploy_pipeline_helm.id
41+
description = "Trigger CD pipeline to deploy on OKE"
42+
display_name = "Trigger Helm Deployment pipeline"
4343
is_pass_all_parameters_enabled = true
4444
}
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11

22
resource "oci_devops_deploy_pipeline" "deploy_pipeline_helm" {
3-
project_id = oci_devops_project.devops_project.id
3+
project_id = oci_devops_project.devops_project.id
44
display_name = "helm-install-pipeline"
5-
description = "Deployment pipeline to install Helm charts on a OKE cluster"
5+
description = "Deployment pipeline to install Helm charts on a OKE cluster"
66
}
77

88

99

10-
resource oci_devops_deploy_stage deploy_helm_stage {
11-
are_hooks_enabled = true
10+
resource "oci_devops_deploy_stage" "deploy_helm_stage" {
11+
are_hooks_enabled = true
1212
deploy_pipeline_id = oci_devops_deploy_pipeline.deploy_pipeline_helm.id
1313
deploy_stage_predecessor_collection {
1414
items {
1515
id = oci_devops_deploy_pipeline.deploy_pipeline_helm.id
1616
}
1717
}
18-
deploy_stage_type = "OKE_HELM_CHART_DEPLOYMENT"
19-
description = "Install the Helm chart on the specified OKE environment"
20-
display_name = "deploy-helm"
21-
helm_chart_deploy_artifact_id = oci_devops_deploy_artifact.flux_operator_chart.id
22-
max_history = 5
23-
namespace = "$${namespace}"
18+
deploy_stage_type = "OKE_HELM_CHART_DEPLOYMENT"
19+
description = "Install the Helm chart on the specified OKE environment"
20+
display_name = "deploy-helm"
21+
helm_chart_deploy_artifact_id = oci_devops_deploy_artifact.flux_operator_chart.id
22+
max_history = 5
23+
namespace = "$${namespace}"
2424
oke_cluster_deploy_environment_id = var.is_oke_cluster_private ? oci_devops_deploy_environment.oke_environment_private.0.id : oci_devops_deploy_environment.oke_environment_public.0.id
25-
purpose = "EXECUTE_HELM_UPGRADE"
26-
release_name = "$${chart_name}"
25+
purpose = "EXECUTE_HELM_UPGRADE"
26+
release_name = "$${chart_name}"
2727
rollback_policy {
2828
policy_type = "AUTOMATED_STAGE_ROLLBACK_POLICY"
2929
}
30-
should_skip_crds = false
31-
timeout_in_seconds = "300"
30+
should_skip_crds = false
31+
timeout_in_seconds = "300"
3232
values_artifact_ids = [oci_devops_deploy_artifact.flux_operator_values.id]
3333
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
resource "oci_devops_deploy_environment" "oke_environment_private" {
22
deploy_environment_type = "OKE_CLUSTER"
33
project_id = oci_devops_project.devops_project.id
4-
cluster_id = var.oke_cluster_id
5-
display_name = var.oke_environment_name
6-
description = var.oke_environment_description
4+
cluster_id = var.oke_cluster_id
5+
display_name = var.oke_environment_name
6+
description = var.oke_environment_description
77
network_channel {
88
network_channel_type = "PRIVATE_ENDPOINT_CHANNEL"
99
subnet_id = var.oke_worker_subnet_id
10-
nsg_ids = var.oke_worker_nsg_id != null ? [var.oke_worker_nsg_id] : []
10+
nsg_ids = var.oke_worker_nsg_id != null ? [var.oke_worker_nsg_id] : []
1111
}
1212
count = var.is_oke_cluster_private ? 1 : 0
1313
}
1414

1515
resource "oci_devops_deploy_environment" "oke_environment_public" {
1616
deploy_environment_type = "OKE_CLUSTER"
1717
project_id = oci_devops_project.devops_project.id
18-
cluster_id = var.oke_cluster_id
19-
display_name = var.oke_environment_name
20-
description = var.oke_environment_description
21-
count = var.is_oke_cluster_private ? 0 : 1
18+
cluster_id = var.oke_cluster_id
19+
display_name = var.oke_environment_name
20+
description = var.oke_environment_description
21+
count = var.is_oke_cluster_private ? 0 : 1
2222
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
locals {
2-
region_key = lower([for s in data.oci_identity_region_subscriptions.oci_region_subscriptions.region_subscriptions : s if s.region_name == var.region][0].region_key)
3-
namespace = data.oci_artifacts_container_configuration.ocir_config.namespace
2+
region_key = lower([for s in data.oci_identity_region_subscriptions.oci_region_subscriptions.region_subscriptions : s if s.region_name == var.region][0].region_key)
3+
namespace = data.oci_artifacts_container_configuration.ocir_config.namespace
44
base_repo_path = "repos/${var.gitops_agent}"
55
}

app-dev/devops-and-containers/oke/oke-gitops/modules/devops/project.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
resource "oci_ons_notification_topic" "devops_notification_topic" {
22
compartment_id = var.compartment_id
33
name = var.notification_topic_name
4-
description = var.notification_topic_description
5-
count = var.create_notification_topic ? 1 : 0
4+
description = var.notification_topic_description
5+
count = var.create_notification_topic ? 1 : 0
66
}
77

88
resource "oci_devops_project" "devops_project" {
99
compartment_id = var.compartment_id
1010
name = var.devops_project_name
11-
description = var.devops_project_description
11+
description = var.devops_project_description
1212
notification_config {
13-
topic_id = var.create_notification_topic? oci_ons_notification_topic.devops_notification_topic.0.id : var.notification_topic_id
13+
topic_id = var.create_notification_topic ? oci_ons_notification_topic.devops_notification_topic.0.id : var.notification_topic_id
1414
}
1515
}
1616

1717
resource "oci_logging_log_group" "devops_log_group" {
1818
compartment_id = var.compartment_id
1919
display_name = var.devops_log_group_name
20-
description = var.devops_log_group_description
20+
description = var.devops_log_group_description
2121
}
2222

2323
resource "oci_logging_log" "devops_log" {

0 commit comments

Comments
 (0)