xargo.gitops.platform.upbound.io
kind: Composition
apiVersion: apiextensions.crossplane.io/v1
metadata:
name: xargo.gitops.platform.upbound.io
creationTimestamp: null
labels:
type: gitops
spec:
compositeTypeRef:
apiVersion: gitops.platform.upbound.io/v1alpha1
kind: XArgo
mode: Pipeline
pipeline:
- step: patch-and-transform
functionRef:
name: crossplane-contrib-function-patch-and-transform
input:
apiVersion: pt.fn.crossplane.io/v1beta1
kind: Resources
patchSets:
- name: Common
patches:
- fromFieldPath: metadata.labels
toFieldPath: metadata.labels
type: FromCompositeFieldPath
- fromFieldPath: metadata.annotations
toFieldPath: metadata.annotations
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.providerConfigName
toFieldPath: spec.providerConfigRef.name
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.deletionPolicy
toFieldPath: spec.deletionPolicy
type: FromCompositeFieldPath
resources:
- base:
apiVersion: helm.crossplane.io/v1beta1
kind: Release
spec:
forProvider:
chart:
name: argo-cd
repository: https://argoproj.github.io/argo-helm
namespace: argocd
values:
applicationSet:
metrics:
enabled: true
service:
annotations:
prometheus.io/scrape: true
replicaCount: 1
configs:
cm:
application.resourceTrackingMethod: annotation
resource.customizations: >
"*.upbound.io/*":
health.lua: |
health_status = {
status = "Progressing",
message = "Provisioning ..."
}
local function contains (table, val)
for i, v in ipairs(table) do
if v == val then
return true
end
end
return false
end
local has_no_status = {
"ProviderConfig",
"ProviderConfigUsage"
}
if obj.status == nil and contains(has_no_status, obj.kind) then
health_status.status = "Healthy"
health_status.message = "Resource is up-to-date."
return health_status
end
if obj.status == nil or obj.status.conditions == nil then
if obj.kind == "ProviderConfig" and obj.status.users ~= nil then
health_status.status = "Healthy"
health_status.message = "Resource is in use."
return health_status
end
return health_status
end
for i, condition in ipairs(obj.status.conditions) do
if condition.type == "LastAsyncOperation" then
if condition.status == "False" then
health_status.status = "Degraded"
health_status.message = condition.message
return health_status
end
end
if condition.type == "Synced" then
if condition.status == "False" then
health_status.status = "Degraded"
health_status.message = condition.message
return health_status
end
end
if condition.type == "Ready" then
if condition.status == "True" then
health_status.status = "Healthy"
health_status.message = "Resource is up-to-date."
return health_status
end
end
end
return health_status
"*.crossplane.io/*":
health.lua: |
health_status = {
status = "Progressing",
message = "Provisioning ..."
}
local function contains (table, val)
for i, v in ipairs(table) do
if v == val then
return true
end
end
return false
end
local has_no_status = {
"Composition",
"CompositionRevision",
"DeploymentRuntimeConfig",
"ControllerConfig"
}
if obj.status == nil and contains(has_no_status, obj.kind) then
health_status.status = "Healthy"
health_status.message = "Resource is up-to-date."
return health_status
end
if obj.status == nil or obj.status.conditions == nil then
return health_status
end
for i, condition in ipairs(obj.status.conditions) do
if condition.type == "LastAsyncOperation" then
if condition.status == "False" then
health_status.status = "Degraded"
health_status.message = condition.message
return health_status
end
end
if condition.type == "Synced" then
if condition.status == "False" then
health_status.status = "Degraded"
health_status.message = condition.message
return health_status
end
end
if contains({"Ready", "Healthy", "Offered", "Established"}, condition.type) then
if condition.status == "True" then
health_status.status = "Healthy"
health_status.message = "Resource is up-to-date."
return health_status
end
end
end
return health_status
params:
application.namespaces: cluster-*
controller:
env:
- name: ARGOCD_K8S_CLIENT_QPS
value: "300"
metrics:
enabled: true
service:
annotations:
prometheus.io/scrape: true
replicas: 1
dex:
enabled: false
redis-ha:
enabled: true
repoServer:
autoscaling:
enabled: true
minReplicas: 1
metrics:
enabled: true
service:
annotations:
prometheus.io/scrape: true
resources:
limits:
cpu: 200m
memory: 512Mi
requests:
cpu: 100m
memory: 256Mi
server:
autoscaling:
enabled: true
minReplicas: 1
metrics:
enabled: true
service:
annotations:
prometheus.io/scrape: true
resources:
limits:
cpu: 200m
memory: 512Mi
requests:
cpu: 100m
memory: 256Mi
service:
type: LoadBalancer
name: releaseArgo
patches:
- patchSetName: Common
type: PatchSet
- fromFieldPath: spec.parameters.ingressUrl
toFieldPath: spec.forProvider.values.server.url
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.ingressUrl
toFieldPath: spec.forProvider.values.configs.cm.url
transforms:
- string:
fmt: https://%s
type: Format
type: string
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.oidcConfig
toFieldPath: spec.forProvider.values.server.config[oidc.config]
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.resourceInclusions
toFieldPath: spec.forProvider.values.configs.cm[resource.inclusions]
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.resourceExclusions
toFieldPath: spec.forProvider.values.configs.cm[resource.exclusions]
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.operators.argocd.version
toFieldPath: spec.forProvider.chart.version
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.providerConfigName
toFieldPath: metadata.annotations[crossplane.io/external-name]
transforms:
- match:
fallbackValue: null
patterns:
- regexp: .*
result: argocd
type: regexp
type: match
type: FromCompositeFieldPath
- base:
apiVersion: kubernetes.crossplane.io/v1alpha2
kind: Object
spec:
forProvider:
manifest:
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
namespace: argocd
spec:
generators:
- matrix:
generators:
- git: {}
- list:
elements: []
elementsYaml: "{{ .key.components | toJson }}"
goTemplate: true
goTemplateOptions:
- missingkey=error
template:
metadata:
name: "{{.name}}"
spec:
destination:
namespace: "{{.namespace}}"
server: "{{.server}}"
project: "{{.project}}"
source:
path: "{{.folder}}"
repoURL: "{{.repoUrl}}"
targetRevision: "{{.version}}"
syncPolicy:
automated:
selfHeal: true
syncOptions:
- CreateNamespace=true
name: argoApplicationSet
patches:
- patchSetName: Common
type: PatchSet
- fromFieldPath: spec.parameters.providerConfigName
toFieldPath: spec.forProvider.manifest.metadata.name
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.source.git.url
toFieldPath: spec.forProvider.manifest.spec.generators[0].matrix.generators[0].git.repoURL
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.source.git.path
toFieldPath: spec.forProvider.manifest.spec.generators[0].matrix.generators[0].git.files[0].path
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.source.git.ref.name
toFieldPath: spec.forProvider.manifest.spec.generators[0].matrix.generators[0].git.revision
type: FromCompositeFieldPath
writeConnectionSecretsToNamespace: upbound-system
© 2022 Upbound, Inc.
Discover the building blocksfor your internal cloud platform.