Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

A Kubernetes controller designed to manage add-on compliance for a fleet of clusters.

License

Notifications You must be signed in to change notification settings

projectsveltos/addon-compliance-controller

Repository files navigation

CI Go Report Card Slack License

libsveltos

Please refere to sveltos documentation.

Archived

This repository (sveltos addon compliance) is archived and is no longer actively maintained. The code is still available for reference, but no new features or bug fixes will be added.

What this repository is

Sveltos has the ability to deploy various types of Kubernetes addons across multiple clusters. It supports Helm charts, Kustomize files, YAMLs, Jsonnet, and Carvel ytt. Sveltos can retrieve configuration from diverse sources, including Git repositories. Prior to deploying addons, Sveltos can be directed to validate them against a predefined set of openapi rules.

Within this repository, you'll find a Kubernetes controller that can fetch addon compliances from different sources and provide them to the addon controller. This enables the addon controller to validate addons before deployment, ensuring that no Kubernetes addons are deployed that violate your own rules.

Following is an example enforcing deployments have at least 3 replicas enforced in any cluster matching the label selector env=production

apiVersion: lib.projectsveltos.io/v1alpha1
kind: AddonCompliance
metadata:
 name: depl-replica
spec:
  clusterSelector: env=production
  openAPIValidationRefs:
  - namespace: default
    name: openapi-deployment
    kind: ConfigMap
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: openapi-deployment
  namespace: default
data:
  openapi.yaml: |
    openapi: 3.0.0
    info:
      title: Kubernetes Replica Validation
      version: 1.0.0

    paths:
      /apis/apps/v1/namespaces/{namespace}/deployments:
        post:
          parameters:
            - in: path
              name: namespace
              required: true
              schema:
                type: string
                minimum: 1
              description: The namespace of the resource
          summary: Create/Update a new deployment
          requestBody:
            required: true
            content:
              application/json:
                schema:
                  $ref: '#/components/schemas/Deployment'
          responses:
            '200':
              description: OK
            '400':
              description: Invalid Deployment. Each deployment in a production cluster requires at least 3 replicas

    components:
      schemas:
        Deployment:
          type: object
          properties:
            metadata:
              type: object
              properties:
                name:
                  type: string
            spec:
              type: object
              properties:
                replicas:
                  type: integer
                  minimum: 3

Contributing

❤️ Your contributions are always welcome! If you want to contribute, have questions, noticed any bug or want to get the latest project news, you can connect with us in the following ways:

  1. Open a bug/feature enhancement on github contributions welcome
  2. Chat with us on the Slack in the #projectsveltos channel Slack
  3. Contact Us

License

Copyright 2022.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.