Skip to content

Commit

Permalink
fix(k0s-config): correct changes for ArgoCD Apps 2.0 upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
jilgue committed Dec 8, 2024
1 parent 1b23c2b commit 36ad5f7
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 21 deletions.
2 changes: 1 addition & 1 deletion instances.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ data "oci_core_images" "this" {

compartment_id = var.compartment_id
operating_system = "Canonical Ubuntu"
operating_system_version = "22.04"
operating_system_version = "24.04"
shape = each.value.shape
}

Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ resource "local_file" "k0sctl" {
private_ip = module.instance["controllerworker"].private_ip[0]
public_ip = module.instance["controllerworker"].public_ip[0]
k0s_version = var.k0s_version
manifests_source = var.manifests_source
projects = var.projects
enable_argocd = var.enable_argocd
enable_argocd_apps = var.enable_argocd_apps
enable_nginx = var.enable_nginx
Expand Down
42 changes: 32 additions & 10 deletions templates/k0sctl.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,42 @@ spec:
namespace: argocd
order: 3
values: |
applications:
- name: manifests
applications: %{if length(projects) == 0~}{}%{else}
%{for project in projects}
${project.name}:
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
project: default
project: ${project.name}
source:
repoURL: ${manifests_source.repo_url}
targetRevision: ${manifests_source.target_revision}
path: ${manifests_source.path}
directory:
recurse: ${manifests_source.directory_recurse}
repoURL: ${project.source.repo_url}
targetRevision: ${project.source.target_revision}
path: ${project.source.path}
%{if project.source.plugin != ""}
plugin:
name: ${project.source.plugin}
%{endif}
destination:
server: https://kubernetes.default.svc
namespace: argocd
%{if project.auto_sync}
syncPolicy:
automated:
prune: true
%{endif~}
%{endfor~}%{endif~}

projects: %{if length(projects) == 0~}{}%{else}
%{for project in projects}
${project.name}:
namespace: argocd
description: Project for ${project.name}
sourceRepos:
- '${project.source.repo_url}'
destinations:
- namespace: argocd
server: https://kubernetes.default.svc
- namespace: ${project.destination_namespace}
server: https://kubernetes.default.svc
%{endfor~}%{endif~}

%{ endif }
%{ endif }
24 changes: 15 additions & 9 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,23 @@ variable "argocd_host" {
default = null
}

variable "manifests_source" {
description = "A yaml object with source variables for ArgoCD application manifests"
type = object({
repo_url = string
target_revision = string
path = string
directory_recurse = optional(bool, false)
})
default = null
variable "projects" {
description = "ArgoCD projects"
type = list(object({
name = string
source = object({
repo_url = string
target_revision = string
path = optional(string, ".")
plugin = optional(string, "")
})
destination_namespace = string
auto_sync = optional(bool, true)
}))
default = []
}


variable "argocd_values" {
description = "Replace the default ArgoCD values.yaml with this yaml object"
default = {}
Expand Down

0 comments on commit 36ad5f7

Please sign in to comment.