Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow KustomizationRef.Path and PolicyRef.Path to be template #533

Merged
merged 1 commit into from
May 8, 2024

Conversation

gianlucam76
Copy link
Member

This allow Sveltos to decide which path to use at run-time.

For instance, this repo https://github.com/gianlucam76/kustomize has two directories with kustomize files:

  1. production
  2. pre-production

The only difference between the two is that Deployment in production/helloWorld has replicas set to 3, while the Deployment in pre-production/helloWorld has replicase set to 1.

By creating this ClusterProfile:

apiVersion: config.projectsveltos.io/v1alpha1
kind: ClusterProfile
metadata:
  name: flux-system
spec:
  clusterSelector: region=west
  syncMode: Continuous
  kustomizationRefs:
  - namespace: flux-system
    name: flux-system
    kind: GitRepository
    path: '{{ index .Cluster.metadata.annotations "environment" }}/helloWorld'
    targetNamespace: eng

For every matching cluster, Sveltos will first instantiate the path so:

  1. picking production/helloWorld path if cluster has annotation environment: production
  2. picking pre-production/helloWorld path if cluster has annotation environment: pre-production

Closes #532
Closes 278

This allow Sveltos to decide which path to use at run-time.

For instance, this repo https://github.com/gianlucam76/kustomize
has two directories with kustomize files:

1. production
2. pre-production

The only difference between the two is that Deployment in production/helloWorld
has replicas set to 3, while the Deployment in pre-production/helloWorld has
replicase set to 1.

By creating this ClusterProfile:

```yaml
apiVersion: config.projectsveltos.io/v1alpha1
kind: ClusterProfile
metadata:
  name: flux-system
spec:
  clusterSelector: region=west
  syncMode: Continuous
  kustomizationRefs:
  - namespace: flux-system
    name: flux-system
    kind: GitRepository
    path: '{{ index .Cluster.metadata.annotations "environment" }}/helloWorld'
    targetNamespace: eng
```

For every matching cluster, Sveltos will first instantiate the __path__ so:

1. picking production/helloWorld path if cluster has annotation ```environment: production```
2. picking pre-production/helloWorld path if cluster has annotation ```environment: pre-production```
@gianlucam76 gianlucam76 merged commit a13c0a2 into projectsveltos:dev May 8, 2024
5 checks passed
@gianlucam76 gianlucam76 deleted the kustomize-path branch July 17, 2024 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant