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

Commit

Permalink
Merge pull request #5 from gianlucam76/prep
Browse files Browse the repository at this point in the history
Prepare dev to main merge
  • Loading branch information
gianlucam76 authored Jun 15, 2023
2 parents 1a53d9c + d32c7b2 commit dffe0e1
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ARCH ?= amd64
OS ?= $(shell uname -s | tr A-Z a-z)
K8S_LATEST_VER ?= $(shell curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
export CONTROLLER_IMG ?= $(REGISTRY)/$(IMAGE_NAME)
TAG ?= v0.11.0
TAG ?= main

# Get cluster-api version and build ldflags
clusterapi := $(shell go list -m sigs.k8s.io/cluster-api)
Expand Down
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,74 @@ Sveltos has the ability to deploy various types of Kubernetes addons across mult

Within this repository, you'll find a Kubernetes controller that can fetch addon constraints 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`

```yaml
apiVersion: lib.projectsveltos.io/v1alpha1
kind: AddonConstraint
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:
Expand Down
2 changes: 1 addition & 1 deletion config/default/manager_image_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ spec:
spec:
containers:
# Change the value of image field below to your controller image URL
- image: projectsveltos/addon-constraint-controller-amd64:v0.11.0
- image: projectsveltos/addon-constraint-controller-amd64:main
name: manager
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/onsi/ginkgo/v2 v2.9.5
github.com/onsi/gomega v1.27.7
github.com/pkg/errors v0.9.1
github.com/projectsveltos/libsveltos v0.11.0
github.com/projectsveltos/libsveltos v0.11.1-0.20230615070804-fbfe41402262
github.com/spf13/pflag v1.0.5
k8s.io/api v0.26.2
k8s.io/apiextensions-apiserver v0.26.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/projectsveltos/libsveltos v0.11.0 h1:/+S5GkyLpkd0BH8VVchJkjOf6ZLPS0sh0P2qNBkOweQ=
github.com/projectsveltos/libsveltos v0.11.0/go.mod h1:+g9FDJ9UBZ5vUxDAAqak79PblSYbeNZXc+1iZUOU3ik=
github.com/projectsveltos/libsveltos v0.11.1-0.20230615070804-fbfe41402262 h1:cZwARP5xUSJ2zY9HZNY4d1x8cClR7WZVHXF/xCecuTA=
github.com/projectsveltos/libsveltos v0.11.1-0.20230615070804-fbfe41402262/go.mod h1:+g9FDJ9UBZ5vUxDAAqak79PblSYbeNZXc+1iZUOU3ik=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
Expand Down
2 changes: 1 addition & 1 deletion manifest/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ spec:
- --v=5
command:
- /manager
image: projectsveltos/addon-constraint-controller-amd64:v0.11.0
image: projectsveltos/addon-constraint-controller-amd64:main
livenessProbe:
httpGet:
path: /healthz
Expand Down

0 comments on commit dffe0e1

Please sign in to comment.