Skip to content

Commit

Permalink
Add suggestions from review
Browse files Browse the repository at this point in the history
  • Loading branch information
DebakelOrakel committed Feb 23, 2024
1 parent 52ca09e commit 6abe77a
Show file tree
Hide file tree
Showing 17 changed files with 251 additions and 312 deletions.
2 changes: 1 addition & 1 deletion class/argocd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ parameters:
filters:
- type: jsonnet
path: ${_instance}//10_operator/
filter: postprocess/fix_crd.jsonnet
filter: postprocess/fix_manifests.jsonnet
1 change: 1 addition & 0 deletions class/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ parameters:
gitlab-dev.syn.tools ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKtv4stHQjApa7wkgvgo4dB52qLzI/zN2Us+89cQXXm0
operator:
migrate: false
conversion_webhook: false
namespace: syn-argocd-operator
images:
argocd_operator: ${argocd:images:argocd_operator}
Expand Down
12 changes: 9 additions & 3 deletions component/argocd.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ local params = inv.parameters.argocd;
local common = import 'common.libsonnet';
local isOpenshift = std.startsWith(params.distribution, 'openshift');

local resync_string = if std.get(params, 'resync_seconds', 0) > 0 then std.format('%dm0s', std.mod(params.resync, 60)) else params.resync_time;
local resync_string =
if std.get(params, 'resync_seconds', 0) > 0 then
std.trace(
'Parameter `resync_seconds` is deprecated. Please update your config to use `resync_time`',
std.format('%dm0s', std.mod(params.resync, 60)),
)
else
params.resync_time;

local applicationController = {
processors: {
Expand Down Expand Up @@ -299,7 +306,6 @@ local argocd(name) =
|||,
},
{
// `ResourceCustomizations` is getting deprecated, however, the new `ResourceHealthChecks` does not currently expose the `health.lua.useOpenLibs` flag
group: 'operators.coreos.com',
kind: 'Subscription',
check: |||
Expand Down Expand Up @@ -392,5 +398,5 @@ local webhook_certs = [
// Manually adding certificate for conversion webhook
// as the upstream kustomize is broken.
// 2023/02/19 sfe
'../10_operator_webhook_certs': webhook_certs,
[if params.operator.conversion_webhook then '../10_operator_webhook_certs']: webhook_certs,
}
13 changes: 10 additions & 3 deletions component/operator.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ local params = inv.parameters.argocd.operator;
local image = params.images.argocd_operator;
local rbac = params.images.kube_rbac_proxy;

local kustomize_input = params.kustomize_input {
local kustomize_patch_scopens = if std.length(params.cluster_scope_namespaces) > 0 then {
patches+: [
if std.length(params.cluster_scope_namespaces) > 0 then {
{
patch: std.format(|||
- op: add
path: "/spec/template/spec/containers/1/env/-"
Expand All @@ -22,6 +22,10 @@ local kustomize_input = params.kustomize_input {
name: 'argocd-operator-controller-manager',
},
},
],
} else {};
local kustomize_patch_conversion = if params.conversion_webhook then {
patches+: [
{
patch: |||
- op: add
Expand All @@ -36,7 +40,10 @@ local kustomize_input = params.kustomize_input {
},
},
],
};
} else {};
local kustomize_input = params.kustomize_input
+ kustomize_patch_scopens
+ kustomize_patch_conversion;

com.Kustomization(
params.kustomization_url,
Expand Down
34 changes: 34 additions & 0 deletions docs/modules/ROOT/pages/how-tos/upgrade-v7-v8.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
= Upgrade `component-argocd` from `v7.x` to `v8.x`

== Migration to ArgoCD Operator

As of component version 8, the ArgoCD operator uses a new api version `argoproj.io/v1beta1`.
If there are other unmanaged ArgoCD deployed, you need to enable the conversion webhook.

=== 1. Upgrade component-argocd with conversion webhook flag

The first time you roll out component-argocd v6.x, set the following configuration in your hierarchy:

[source,yaml]
----
parameters:
argocd:
operator:
conversion_webhook: true
----

Roll out the upgrade with this configuration, and wait until:
* The ArgoCD operator deployment is rolled out.
* All unmanaged ArgoCD CR are updated.
[source,shell]
----
kubectl --as cluster-admin get argocds -A -ocustom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,API:.apiVersion'
NAMESPACE NAME API
openshift-gitops openshift-gitops argoproj.io/v1beta1
syn syn-argocd argoproj.io/v1beta1
----


=== 2. Remove the migration flag to complete the migration

After the first rollout of v8.x, the conversion webhook flag can be removed.
1 change: 1 addition & 0 deletions docs/modules/ROOT/partials/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.How-tos
* xref:how-tos/upgrade-v3-v4.adoc[Upgrade from `v3.x` to `v4.x`]
* xref:how-tos/upgrade-v5-v6.adoc[Upgrade from `v5.5.x` to `v6.x`]
* xref:how-tos/upgrade-v7-v8.adoc[Upgrade from `v7.x` to `v8.x`]
.References
* xref:references/parameters.adoc[Parameters]
17 changes: 0 additions & 17 deletions postprocess/fix_crd.jsonnet

This file was deleted.

30 changes: 30 additions & 0 deletions postprocess/fix_manifests.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
local com = import 'lib/commodore.libjsonnet';

local inv = com.inventory();
local params = inv.parameters.argocd.operator;

local file_apiext_argocd = com.yaml_load(std.extVar('output_path') + '/apiextensions.k8s.io_v1_customresourcedefinition_argocds.argoproj.io.yaml');
local file_deployment = com.yaml_load(std.extVar('output_path') + '/apps_v1_deployment_syn-argocd-operator-controller-manager.yaml');

{
'apiextensions.k8s.io_v1_customresourcedefinition_argocds.argoproj.io': file_apiext_argocd {
metadata+: {
creationTimestamp: null,
annotations+: {
[if params.conversion_webhook then 'cert-manager.io/inject-ca-from']: params.namespace + '/serving-cert',
},
},
spec+: {
[if !params.conversion_webhook then 'conversion']: { strategy: 'None' },
},
},
'apps_v1_deployment_syn-argocd-operator-controller-manager': file_deployment {
spec+: {
template+: {
spec+: {
volumes: [ { name: 'cert', emptyDir: {} } ],
},
},
},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,12 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: syn-argocd-operator/serving-cert
controller-gen.kubebuilder.io/version: v0.6.1
creationTimestamp: null
name: argocds.argoproj.io
spec:
conversion:
strategy: Webhook
webhook:
clientConfig:
service:
name: syn-argocd-operator-webhook-service
namespace: syn-argocd-operator
path: /convert
conversionReviewVersions:
- v1alpha1
- v1beta1
strategy: None
group: argoproj.io
names:
kind: ArgoCD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,66 +16,62 @@ spec:
control-plane: argocd-operator
spec:
containers:
- args:
- --secure-listen-address=0.0.0.0:8443
- --upstream=http://127.0.0.1:8080/
- --logtostderr=true
- --v=10
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.15.0
name: kube-rbac-proxy
ports:
- containerPort: 8443
name: https
- args:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
- --leader-elect
command:
- /manager
env:
- name: WATCH_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.annotations['olm.targetNamespaces']
- name: ARGOCD_CLUSTER_CONFIG_NAMESPACES
value: syn
- name: ENABLE_CONVERSION_WEBHOOK
value: "true"
image: quay.io/argoprojlabs/argocd-operator:v0.8.0
livenessProbe:
httpGet:
path: /healthz
port: 8081
initialDelaySeconds: 15
periodSeconds: 20
name: manager
ports:
- containerPort: 9443
name: webhook-server
protocol: TCP
readinessProbe:
httpGet:
path: /readyz
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
volumeMounts:
- mountPath: /tmp/k8s-webhook-server/serving-certs
name: cert
readOnly: true
- args:
- --secure-listen-address=0.0.0.0:8443
- --upstream=http://127.0.0.1:8080/
- --logtostderr=true
- --v=10
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.15.0
name: kube-rbac-proxy
ports:
- containerPort: 8443
name: https
- args:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
- --leader-elect
command:
- /manager
env:
- name: WATCH_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.annotations['olm.targetNamespaces']
- name: ARGOCD_CLUSTER_CONFIG_NAMESPACES
value: syn
image: quay.io/argoprojlabs/argocd-operator:v0.8.0
livenessProbe:
httpGet:
path: /healthz
port: 8081
initialDelaySeconds: 15
periodSeconds: 20
name: manager
ports:
- containerPort: 9443
name: webhook-server
protocol: TCP
readinessProbe:
httpGet:
path: /readyz
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
volumeMounts:
- mountPath: /tmp/k8s-webhook-server/serving-certs
name: cert
readOnly: true
securityContext:
runAsNonRoot: true
serviceAccountName: syn-argocd-operator-controller-manager
terminationGracePeriodSeconds: 10
volumes:
- name: cert
secret:
defaultMode: 420
secretName: webhook-server-cert
- emptyDir: {}
name: cert
27 changes: 0 additions & 27 deletions tests/golden/defaults/argocd/argocd/10_operator_webhook_certs.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,12 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: syn-argocd-operator/serving-cert
controller-gen.kubebuilder.io/version: v0.6.1
creationTimestamp: null
name: argocds.argoproj.io
spec:
conversion:
strategy: Webhook
webhook:
clientConfig:
service:
name: syn-argocd-operator-webhook-service
namespace: syn-argocd-operator
path: /convert
conversionReviewVersions:
- v1alpha1
- v1beta1
strategy: None
group: argoproj.io
names:
kind: ArgoCD
Expand Down
Loading

0 comments on commit 6abe77a

Please sign in to comment.