diff --git a/docs/addons/addons.md b/docs/addons/addons.md index d51e4cd0..84387c0b 100644 --- a/docs/addons/addons.md +++ b/docs/addons/addons.md @@ -81,6 +81,7 @@ cluster13 true v1.26.9+rke2r1 env=prod,sveltos-agent=present The third step is to create a ClusterProfile Kubernetes resource and apply it to the **management** cluster. ```yaml +cat > clusterprofile_kyverno.yaml < clusterprofile_nginx_ingress.yaml < clusterprofile_kyverno.yaml < clusterprofile_kyverno_policies.yaml < nginx_cm.yaml < clusterprofile_deploy_nginx.yaml <give us a :octicons-star-fill-24: if you haven't done so yet. Your support means a lot to us. **Thank you :pray:.** -If you like the project, please [give us a](https://github.com/projectsveltos/sveltos-manager "Kubernetes add-on controller") [:octicons-star-fill-24:{ .heart }](https://github.com/projectsveltos/sveltos-manager "Kubernetes add-on controller") if you haven't done so yet. This will help other people find it and learn more about it. -==} - -[:star: projectsveltos](https://github.com/projectsveltos/sveltos-manager "Kubernetes add-on controller"){ .md-button .md-button--primary } +[:star: projectsveltos](https://github.com/projectsveltos/sveltos-manager "Manage Kubernetes add-ons"){:target="_blank" .md-button} [![Stargazers repo roster for @projectsveltos/addon-controller](http://reporoster.com/stars/projectsveltos/addon-controller)](https://github.com/projectsveltos/addon-controller/stargazers) diff --git a/docs/deployment_order/depends_on.md b/docs/deployment_order/depends_on.md index b08fce86..1f6ee3f5 100644 --- a/docs/deployment_order/depends_on.md +++ b/docs/deployment_order/depends_on.md @@ -125,7 +125,8 @@ spec: !!! note Separate ClusterProfiles promote better organization and maintainability, especially when different teams or individuals manage different ClusterProfiles. -[^1]: To create the ConfigMaps with Kyverno policies used in this example + + ``` $ wget https://raw.githubusercontent.com/kyverno/policies/main/best-practices/disallow-latest-tag/disallow-latest-tag.yaml @@ -135,3 +136,4 @@ $ wget https://raw.githubusercontent.com/kyverno/policies/main/other/res/restric $ kubectl create configmap restrict-wildcard-verbs --from-file restrict-wildcard-verbs.yaml ``` +[^1]: To create the ConfigMaps with Kyverno policies used in this example \ No newline at end of file diff --git a/docs/events/addon_event_deployment.md b/docs/events/addon_event_deployment.md index 177a6e78..8730f5af 100644 --- a/docs/events/addon_event_deployment.md +++ b/docs/events/addon_event_deployment.md @@ -396,7 +396,7 @@ The EventTrigger `OneForEvent` (false by default) field indicates whether to cre In the above example, if we create another Service in the managed cluster with the label set to *sveltos: fv* ```bash -kubectl get services -A --selector=sveltos=fv +$ kubectl get services -A --selector=sveltos=fv NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE default another-service ClusterIP 10.225.134.41 443/TCP 24m default my-service ClusterIP 10.225.166.113 80/TCP 52m @@ -405,7 +405,7 @@ default my-service ClusterIP 10.225.166.113 80/TCP two NetworkPolicies will be created, one per Service. ```bash -kubectl get networkpolicy -A +$ kubectl get networkpolicy -A NAMESPACE NAME POD-SELECTOR AGE default front-another-service app.kubernetes.io/name=MyApp-secure 8m40s default front-my-service app.kubernetes.io/name=MyApp 8m40s @@ -443,13 +443,13 @@ For more examples, have a look [here](addon_event_deployment.md#yet-another-exam Based on the example above, if a Service is deleted, the NetworkPolicy is also removed automatically by Sveltos. ```bash -kubectl get services -A --selector=sveltos=fv +$ kubectl get services -A --selector=sveltos=fv NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE default my-service ClusterIP 10.225.166.113 80/TCP 54m ``` ```bash -kubectl get networkpolicy -A +$ kubectl get networkpolicy -A NAMESPACE NAME POD-SELECTOR AGE default front-my-service app.kubernetes.io/name=MyApp 10m40s ``` diff --git a/docs/events/example_service_event_trigger.md b/docs/events/example_service_event_trigger.md index 9384f621..a0731b63 100644 --- a/docs/events/example_service_event_trigger.md +++ b/docs/events/example_service_event_trigger.md @@ -107,7 +107,7 @@ data: If we have two Service instance in the managed cluster in the namespace `eng` ```bash -kubectl get service -n eng +$ kubectl get service -n eng NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE my-service ClusterIP 10.225.83.46 80/TCP,443/TCP 15m my-service-2 ClusterIP 10.225.108.8 80/TCP,8443/TCP 14m diff --git a/docs/features/rolling_upgrade.md b/docs/features/rolling_upgrade.md index 1d4f90e7..314e05b8 100644 --- a/docs/features/rolling_upgrade.md +++ b/docs/features/rolling_upgrade.md @@ -42,7 +42,7 @@ The __nginx__ ConfigMap contains a Deployment mounting a ConfigMap[^1]. The above ClusterProfile is responsible for deploying both a ConfigMap instance and a Deployment instance, with the latter mounting a ConfigMap. ```bash -& sveltosctl show addons +$ sveltosctl show addons +-----------------------------+---------------------------------+-----------+---------------------+---------+-------------------------------+------------------------------+ | CLUSTER | RESOURCE TYPE | NAMESPACE | NAME | VERSION | TIME | CLUSTER PROFILES | +-----------------------------+---------------------------------+-----------+---------------------+---------+-------------------------------+------------------------------+ diff --git a/docs/features/set.md b/docs/features/set.md index 310185ad..69982cfe 100644 --- a/docs/features/set.md +++ b/docs/features/set.md @@ -43,7 +43,7 @@ This scenario demonstrates active/passive failover with a ClusterSet. We have two Civo clusters registered with Sveltos, all labeled `env:prod`. ``` -kubectl get sveltoscluster -A --show-labels +$ kubectl get sveltoscluster -A --show-labels NAMESPACE NAME READY VERSION LABELS civo cluster1 true v1.29.2+k3s1 env=prod civo cluster2 true v1.28.7+k3s1 env=prod @@ -141,7 +141,7 @@ status: ``` ``` -sveltosctl show addons +$ sveltosctl show addons +---------------+---------------+-----------+----------------+---------+-------------------------------+------------------------+ | CLUSTER | RESOURCE TYPE | NAMESPACE | NAME | VERSION | TIME | PROFILES | +---------------+---------------+-----------+----------------+---------+-------------------------------+------------------------+ @@ -158,7 +158,7 @@ In this example, __cluster2__ was deleted. Sveltos detected that and marked the cluster as not ready ``` -kubectl get sveltoscluster -A +$ kubectl get sveltoscluster -A NAMESPACE NAME READY VERSION civo cluster1 true v1.29.2+k3s1 civo cluster2 v1.28.7+k3s1 @@ -218,7 +218,7 @@ status: ``` ``` -sveltosctl show addons +$ sveltosctl show addons +---------------+---------------+-----------+----------------+---------+-------------------------------+------------------------+ | CLUSTER | RESOURCE TYPE | NAMESPACE | NAME | VERSION | TIME | PROFILES | +---------------+---------------+-----------+----------------+---------+-------------------------------+------------------------+ diff --git a/docs/getting_started/install/quick_start.md b/docs/getting_started/install/quick_start.md index 6eb923e7..db3e915e 100644 --- a/docs/getting_started/install/quick_start.md +++ b/docs/getting_started/install/quick_start.md @@ -34,6 +34,7 @@ To deploy the Kyverno Helm chart in any Kubernetes cluster with labels _env: fv_ !!! example "Example - Helm Chart" ```yaml + cat > clusterprofile_kyverno.yaml < clusterprofile_gateway.yaml < clusterprofile_flux.yaml < techsupport.yaml < techsupport_advanced.yaml < -n -o jsonpath='{.status}' +$ kubectl get clusterprofile -n -o jsonpath='{.status}' ``` ```bash -$ k get clustersummary -n -o jsonpath='{.status}' +$ kubectl get clustersummary -n -o jsonpath='{.status}' ``` We are here to help! Whether you have questions, or issues or need assistance, our Slack channel is the perfect place for you. Click [here](https://app.slack.com/client/T0471SNT5CZ/C06UZCXQLGP) to join us. diff --git a/docs/observability/display_resources.md b/docs/observability/display_resources.md index 1da1d203..1226026e 100644 --- a/docs/observability/display_resources.md +++ b/docs/observability/display_resources.md @@ -392,6 +392,7 @@ To deploy Kyverno and a ClusterPolicy in each managed cluster matching the label - The ConfigMap contains [this](https://kyverno.io/policies/best-practices/disallow-latest-tag/disallow-latest-tag/) Kyverno ClusterPolicy. ```bash - $ wget https://github.com/kyverno/policies/raw/main//best-practices/disallow-latest-tag/disallow-latest-tag.yaml - $ kubectl create configmap kyverno-latest --from-file disallow-latest-tag.yaml + wget https://github.com/kyverno/policies/raw/main//best-practices/disallow-latest-tag/disallow-latest-tag.yaml + + kubectl create configmap kyverno-latest --from-file disallow-latest-tag.yaml ``` diff --git a/docs/template/bring_your_own_controller.md b/docs/template/bring_your_own_controller.md index 7dc03afd..1870cfd4 100644 --- a/docs/template/bring_your_own_controller.md +++ b/docs/template/bring_your_own_controller.md @@ -69,96 +69,99 @@ The following YAML instructions are used to deploy add-ons using Sveltos: 2. The content of the ConfigMap `uploader` in the `default` namespace is deployed by Sveltos on the managed cluster (`deploymentType: Remote`). The contents of this ConfigMap is a Pod instance expressed as a template. Sveltos instantiates the template using information from the bucket instance created in the previous step. This Pod then uploads a file to the newly created bucket on Google Cloud Storage. -## -```yaml -apiVersion: config.projectsveltos.io/v1alpha1 -kind: ClusterProfile -metadata: - name: deploy-resources -spec: - clusterSelector: env=production - templateResourceRefs: - - resource: - apiVersion: demo.projectsveltos.io/v1alpha1 - kind: Bucket - name: sveltos-demo-bucket - identifier: Bucket - policyRefs: - - deploymentType: Local - kind: ConfigMap - name: bucket - namespace: default - - deploymentType: Remote - kind: ConfigMap - name: uploader - namespace: default ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: bucket - namespace: default - annotations: - projectsveltos.io/template: "true" -data: - bucket.yaml: | - apiVersion: demo.projectsveltos.io/v1alpha1 - kind: Bucket +## +!!! example + ```yaml + cat > bucket.yaml < /tmp/hello.txt - gcloud auth activate-service-account --key-file=/var/run/secrets/cloud.google.com/service-account.json - gsutil cp /tmp/hello.txt gs://{{ (index .MgtmResources "Bucket").spec.bucketName }} - volumeMounts: - - name: gcp-sa - mountPath: /var/run/secrets/cloud.google.com/ - readOnly: true - volumes: - - name: gcp-sa - secret: - secretName: gcs-credentials -``` + projectsveltos.io/template: "true" + data: + secret.yaml: | + apiVersion: v1 + kind: Secret + metadata: + name: gcs-credentials + namespace: default + annotations: + bucket: {{ (index .MgtmResources "Bucket").status.bucketURL }} + type: Opaque + data: + service-account.json: {{ (index .MgtmResources "Bucket").status.serviceAccountCredentials }} + pod.yaml: | + apiVersion: v1 + kind: Pod + metadata: + name: create-and-upload-to-gcs + namespace: default + annotations: + bucket: {{ (index .MgtmResources "Bucket").status.bucketURL }} + spec: + containers: + - name: uploader + image: google/cloud-sdk:slim + command: ["bash"] + args: + - "-c" + - | + echo "Hello world" > /tmp/hello.txt + gcloud auth activate-service-account --key-file=/var/run/secrets/cloud.google.com/service-account.json + gsutil cp /tmp/hello.txt gs://{{ (index .MgtmResources "Bucket").spec.bucketName }} + volumeMounts: + - name: gcp-sa + mountPath: /var/run/secrets/cloud.google.com/ + readOnly: true + volumes: + - name: gcp-sa + secret: + secretName: gcs-credentials + EOF + ``` After posting it a Bucket instance is created in the management cluster by Sveltos. diff --git a/docs/template/crossplane.md b/docs/template/crossplane.md index 87a0c7c7..b574bd00 100644 --- a/docs/template/crossplane.md +++ b/docs/template/crossplane.md @@ -26,102 +26,105 @@ The following YAML code: Once the Pod is deployed, it will upload a file to the `my-bucket` bucket. -```yaml -apiVersion: config.projectsveltos.io/v1alpha1 -kind: ClusterProfile -metadata: - name: deploy-resources -spec: - clusterSelector: env=fv - templateResourceRefs: - - resource: - apiVersion: storage.gcp.upbound.io/v1beta1 - kind: Bucket - name: crossplane-bucket-{{ .ClusterNamespace }}-{{ .ClusterName }} - identifier: CrossplaneBucket - - resource: - apiVersion: v1 - kind: Secret - namespace: crossplane-system - name: gcp-secret - identifier: Credentials - policyRefs: - - deploymentType: Local - kind: ConfigMap - name: bucket - namespace: default - - deploymentType: Remote - kind: ConfigMap - name: uploader - namespace: default ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: bucket - namespace: default - annotations: - projectsveltos.io/template: "true" -data: - bucket.yaml: | - apiVersion: storage.gcp.upbound.io/v1beta1 - kind: Bucket +!!! example + ```yaml + cat > crossplane_google_bucket.yaml < /tmp/hello.txt - gcloud auth activate-service-account --key-file=/var/run/secrets/cloud.google.com/service-account.json - gsutil cp /tmp/hello.txt gs://{{ (index .MgmtResources "CrossplaneBucket").metadata.name }} - volumeMounts: - - name: gcp-sa - mountPath: /var/run/secrets/cloud.google.com/ - readOnly: true - volumes: - - name: gcp-sa - secret: - secretName: gcs-credentials -``` \ No newline at end of file + projectsveltos.io/template: "true" + data: + secret.yaml: | + apiVersion: v1 + kind: Secret + metadata: + name: gcs-credentials + namespace: default + annotations: + bucket: "{{ (index .MgmtResources "CrossplaneBucket").status.atProvider.url }}" + type: Opaque + data: + service-account.json: {{ $data:=(index .MgmtResources "Credentials").data }} {{ (index $data "creds") }} + pod.yaml: | + apiVersion: v1 + kind: Pod + metadata: + name: create-and-upload-to-gcs + namespace: default + annotations: + bucket: {{ (index .MgmtResources "CrossplaneBucket").status.atProvider.url }} + spec: + containers: + - name: uploader + image: google/cloud-sdk:slim + command: ["bash"] + args: + - "-c" + - | + echo "Hello world" > /tmp/hello.txt + gcloud auth activate-service-account --key-file=/var/run/secrets/cloud.google.com/service-account.json + gsutil cp /tmp/hello.txt gs://{{ (index .MgmtResources "CrossplaneBucket").metadata.name }} + volumeMounts: + - name: gcp-sa + mountPath: /var/run/secrets/cloud.google.com/ + readOnly: true + volumes: + - name: gcp-sa + secret: + secretName: gcs-credentials + EOF + ``` \ No newline at end of file diff --git a/docs/template/example_multicluster_iteration_template.md b/docs/template/example_multicluster_iteration_template.md index 5a6d3db1..8a5afc67 100644 --- a/docs/template/example_multicluster_iteration_template.md +++ b/docs/template/example_multicluster_iteration_template.md @@ -23,7 +23,7 @@ The use case can be easily achieved by Sveltos with the use of the [templating]( Sveltos `Event Framework` will be used to dynamically detect all **managed** clusters (of type SveltosCluster) that are different from the management cluster. The management cluster has the Sveltos cluster label set to `type:mgmt`. ```yaml ---- +cat > eventsource_eventtrigger.yaml < clusterprofile_nats.yaml < cm_nats_services.yaml < cluster_profile_flux.yaml <