Skip to content

Commit

Permalink
Implement very basic e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dee-kryvenko committed Feb 11, 2025
1 parent 9ae92b4 commit 6e0e4de
Show file tree
Hide file tree
Showing 37 changed files with 672 additions and 163 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
name: E2E Tests

on:
# Disable for now, until we have something to test
# push:
# # This is time consuming and meaningless for ongoing work in a feature branch
# # Open draft PR to trigger E2E
# branches:
# - main
# pull_request:
push:
pull_request:
workflow_dispatch:

jobs:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ endif

.PHONY: install
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply --server-side=true -f -

.PHONY: uninstall
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
Expand All @@ -151,7 +151,7 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified
.PHONY: deploy
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
$(KUSTOMIZE) build config/default | $(KUBECTL) apply --server-side=true -f -

.PHONY: undeploy
undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
Expand Down
2 changes: 2 additions & 0 deletions config/cert-manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources:
- https://github.com/jetstack/cert-manager/releases/download/v1.16.0/cert-manager.yaml
20 changes: 20 additions & 0 deletions config/certmanager/certificate-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# The following manifests contain a self-signed issuer CR and a metrics certificate CR.
# More document can be found at https://docs.cert-manager.io
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
labels:
app.kubernetes.io/name: kubebuilder
app.kubernetes.io/managed-by: kustomize
name: metrics-certs # this name should match the one appeared in kustomizeconfig.yaml
namespace: system
spec:
dnsNames:
# SERVICE_NAME and SERVICE_NAMESPACE will be substituted by kustomize
# replacements in the config/default/kustomization.yaml file.
- SERVICE_NAME.SERVICE_NAMESPACE.svc
- SERVICE_NAME.SERVICE_NAMESPACE.svc.cluster.local
issuerRef:
kind: Issuer
name: selfsigned-issuer
secretName: metrics-server-cert
13 changes: 13 additions & 0 deletions config/certmanager/issuer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# The following manifest contains a self-signed issuer CR.
# More information can be found at https://docs.cert-manager.io
# WARNING: Targets CertManager v1.0. Check https://cert-manager.io/docs/installation/upgrading/ for breaking changes.
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
labels:
app.kubernetes.io/name: kubebuilder
app.kubernetes.io/managed-by: kustomize
name: selfsigned-issuer
namespace: system
spec:
selfSigned: {}
6 changes: 6 additions & 0 deletions config/certmanager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resources:
- issuer.yaml
- certificate-metrics.yaml

configurations:
- kustomizeconfig.yaml
8 changes: 8 additions & 0 deletions config/certmanager/kustomizeconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This configuration is for teaching kustomize how to update name ref substitution
nameReference:
- kind: Issuer
group: cert-manager.io
fieldSpecs:
- kind: Certificate
group: cert-manager.io
path: spec/issuerRef/name
97 changes: 52 additions & 45 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,26 @@ resources:
# crd/kustomization.yaml
#- ../webhook
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required.
#- ../certmanager
- ../certmanager
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
#- ../prometheus
- ../prometheus
# [METRICS] Expose the controller manager metrics service.
- metrics_service.yaml
# [NETWORK POLICY] Protect the /metrics endpoint and Webhook Server with NetworkPolicy.
# Only Pod(s) running a namespace labeled with 'metrics: enabled' will be able to gather the metrics.
# Only CR(s) which requires webhooks and are applied on namespaces labeled with 'webhooks: enabled' will
# be able to communicate with the Webhook Server.
#- ../network-policy
- ../network-policy
# [SAMPLES] Uncomment the following line to enable the samples overlay for testing
#- ../samples

# Uncomment the patches line if you enable Metrics
patches:
# [LOGS] Enable devel zap mode for human readable output
- path: manager_zap_devel.yaml
target:
kind: Deployment

# [METRICS] The following patch will enable the metrics endpoint using HTTPS and the port :8443.
# More info: https://book.kubebuilder.io/reference/metrics
- path: manager_metrics_patch.yaml
Expand All @@ -44,9 +51,9 @@ patches:
# Uncomment the patches line if you enable Metrics and CertManager
# [METRICS-WITH-CERTS] To enable metrics protected with certManager, uncomment the following line.
# This patch will protect the metrics with certManager self-signed certs.
#- path: cert_metrics_manager_patch.yaml
# target:
# kind: Deployment
- path: cert_metrics_manager_patch.yaml
target:
kind: Deployment

# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
# crd/kustomization.yaml
Expand All @@ -56,45 +63,45 @@ patches:

# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix.
# Uncomment the following replacements to add the cert-manager CA injection annotations
#replacements:
# - source: # Uncomment the following block to enable certificates for metrics
# kind: Service
# version: v1
# name: controller-manager-metrics-service
# fieldPath: metadata.name
# targets:
# - select:
# kind: Certificate
# group: cert-manager.io
# version: v1
# name: metrics-certs
# fieldPaths:
# - spec.dnsNames.0
# - spec.dnsNames.1
# options:
# delimiter: '.'
# index: 0
# create: true
#
# - source:
# kind: Service
# version: v1
# name: controller-manager-metrics-service
# fieldPath: metadata.namespace
# targets:
# - select:
# kind: Certificate
# group: cert-manager.io
# version: v1
# name: metrics-certs
# fieldPaths:
# - spec.dnsNames.0
# - spec.dnsNames.1
# options:
# delimiter: '.'
# index: 1
# create: true
#
replacements:
- source: # Uncomment the following block to enable certificates for metrics
kind: Service
version: v1
name: controller-manager-metrics-service
fieldPath: metadata.name
targets:
- select:
kind: Certificate
group: cert-manager.io
version: v1
name: metrics-certs
fieldPaths:
- spec.dnsNames.0
- spec.dnsNames.1
options:
delimiter: '.'
index: 0
create: true

- source:
kind: Service
version: v1
name: controller-manager-metrics-service
fieldPath: metadata.namespace
targets:
- select:
kind: Certificate
group: cert-manager.io
version: v1
name: metrics-certs
fieldPaths:
- spec.dnsNames.0
- spec.dnsNames.1
options:
delimiter: '.'
index: 1
create: true

# - source: # Uncomment the following block if you have any webhook
# kind: Service
# version: v1
Expand Down
4 changes: 4 additions & 0 deletions config/default/manager_zap_devel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This patch adds the args to allow exposing the metrics endpoint
- op: add
path: /spec/template/spec/containers/0/args/0
value: --zap-devel
28 changes: 28 additions & 0 deletions config/e2e/argocd_application_controller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: argocd-application-controller
namespace: system
spec:
replicas: 0
selector:
matchLabels:
app.kubernetes.io/name: argocd-application-controller
argocd.paramount.tech/name: argocd
template:
metadata:
labels:
app.kubernetes.io/name: argocd-application-controller
argocd.paramount.tech/name: argocd
spec:
containers:
- name: argocd-application-controller
image: registry.k8s.io/pause:3.1
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
13 changes: 13 additions & 0 deletions config/e2e/autoscaler_v1alpha1_longestprocessingtimepartition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: autoscaler.argoproj.io/v1alpha1
kind: LongestProcessingTimePartition
metadata:
labels:
app.kubernetes.io/name: argocd-autoscaler
app.kubernetes.io/managed-by: kustomize
name: longestprocessingtimepartition-sample
namespace: system
spec:
loadIndexProviderRef:
apiGroup: autoscaler.argoproj.io
kind: WeightedPNormLoadIndex
name: argocd-autoscaler-weightedpnormloadindex-sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: autoscaler.argoproj.io/v1alpha1
kind: MostWantedTwoPhaseHysteresisEvaluation
metadata:
labels:
app.kubernetes.io/name: argocd-autoscaler
app.kubernetes.io/managed-by: kustomize
name: mostwantedtwophasehysteresisevaluation-sample
namespace: system
spec:
partitionProviderRef:
apiGroup: autoscaler.argoproj.io
kind: LongestProcessingTimePartition
name: argocd-autoscaler-longestprocessingtimepartition-sample
pollingPeriod: 5s
stabilizationPeriod: 1m
minimumSampleSize: 10
18 changes: 18 additions & 0 deletions config/e2e/autoscaler_v1alpha1_prometheuspoll.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: autoscaler.argoproj.io/v1alpha1
kind: PrometheusPoll
metadata:
labels:
app.kubernetes.io/name: argocd-autoscaler
app.kubernetes.io/managed-by: kustomize
name: prometheuspoll-sample
namespace: system
spec:
shardManagerRef:
apiGroup: autoscaler.argoproj.io
kind: SecretTypeClusterShardManager
name: argocd-autoscaler-secrettypeclustershardmanager-sample
period: 5s
address: http://prometheus-operated.prometheus.svc.cluster.local:9090
metrics:
- id: up
query: up
25 changes: 25 additions & 0 deletions config/e2e/autoscaler_v1alpha1_replicasetscaler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: autoscaler.argoproj.io/v1alpha1
kind: ReplicaSetScaler
metadata:
labels:
app.kubernetes.io/name: argocd-autoscaler
app.kubernetes.io/managed-by: kustomize
name: replicasetscaler-sample
namespace: system
spec:
partitionProviderRef:
apiGroup: autoscaler.argoproj.io
kind: MostWantedTwoPhaseHysteresisEvaluation
name: argocd-autoscaler-mostwantedtwophasehysteresisevaluation-sample
shardManagerRef:
apiGroup: autoscaler.argoproj.io
kind: SecretTypeClusterShardManager
name: argocd-autoscaler-secrettypeclustershardmanager-sample
replicaSetControllerRef:
apiGroup: apps
kind: StatefulSet
name: argocd-autoscaler-argocd-application-controller
mode:
# default:
# rolloutRestart: true
# x0y: {}
13 changes: 13 additions & 0 deletions config/e2e/autoscaler_v1alpha1_robustscalingnormalizer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: autoscaler.argoproj.io/v1alpha1
kind: RobustScalingNormalizer
metadata:
labels:
app.kubernetes.io/name: argocd-autoscaler
app.kubernetes.io/managed-by: kustomize
name: robustscalingnormalizer-sample
namespace: system
spec:
metricValuesProviderRef:
apiGroup: autoscaler.argoproj.io
kind: PrometheusPoll
name: argocd-autoscaler-prometheuspoll-sample
12 changes: 12 additions & 0 deletions config/e2e/autoscaler_v1alpha1_secrettypeclustershardmanager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: autoscaler.argoproj.io/v1alpha1
kind: SecretTypeClusterShardManager
metadata:
labels:
app.kubernetes.io/name: argocd-autoscaler
app.kubernetes.io/managed-by: kustomize
name: secrettypeclustershardmanager-sample
namespace: system
spec:
labelSelector:
matchLabels:
test.argocd.argoproj.io/secret-type: cluster
17 changes: 17 additions & 0 deletions config/e2e/autoscaler_v1alpha1_weightedpnormloadindex.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: autoscaler.argoproj.io/v1alpha1
kind: WeightedPNormLoadIndex
metadata:
labels:
app.kubernetes.io/name: argocd-autoscaler
app.kubernetes.io/managed-by: kustomize
name: weightedpnormloadindex-sample
namespace: system
spec:
metricValuesProviderRef:
apiGroup: autoscaler.argoproj.io
kind: RobustScalingNormalizer
name: argocd-autoscaler-robustscalingnormalizer-sample
p: 1
weights:
- id: up
weight: "1"
14 changes: 14 additions & 0 deletions config/e2e/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace: argocd-autoscaler-system
namePrefix: argocd-autoscaler-
## Append samples of your project ##
resources:
- argocd_application_controller.yaml
- secret_type_cluster.yaml
- autoscaler_v1alpha1_secrettypeclustershardmanager.yaml
- autoscaler_v1alpha1_prometheuspoll.yaml
- autoscaler_v1alpha1_robustscalingnormalizer.yaml
- autoscaler_v1alpha1_weightedpnormloadindex.yaml
- autoscaler_v1alpha1_longestprocessingtimepartition.yaml
- autoscaler_v1alpha1_mostwantedtwophasehysteresisevaluation.yaml
- autoscaler_v1alpha1_replicasetscaler.yaml
# +kubebuilder:scaffold:manifestskustomizesamples
11 changes: 11 additions & 0 deletions config/e2e/secret_type_cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Secret
metadata:
labels:
test.argocd.argoproj.io/secret-type: cluster
name: sample-cluster
namespace: system
stringData:
name: sample-cluster
server: https://kubernetes.default.svc
type: Opaque
Loading

0 comments on commit 6e0e4de

Please sign in to comment.