Skip to content

Commit

Permalink
ClusterResourceSet feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Sedef committed May 28, 2020
1 parent e8dea67 commit ae45ada
Show file tree
Hide file tree
Showing 24 changed files with 1,672 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ generate-go-core: $(CONTROLLER_GEN) $(CONVERSION_GEN)
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \
paths=./api/... \
paths=./$(EXP_DIR)/api/... \
paths=./$(EXP_DIR)/clusterresourceset/api/... \
paths=./cmd/clusterctl/...
$(CONVERSION_GEN) \
--input-dirs=./api/v1alpha2 \
Expand Down Expand Up @@ -275,6 +276,8 @@ generate-core-manifests: $(CONTROLLER_GEN) ## Generate manifests for the core pr
paths=./controllers/... \
paths=./$(EXP_DIR)/api/... \
paths=./$(EXP_DIR)/controllers/... \
paths=./$(EXP_DIR)/clusterresourceset/api/... \
paths=./$(EXP_DIR)/clusterresourceset/controllers/... \
crd:crdVersions=v1 \
rbac:roleName=manager-role \
output:crd:dir=./config/crd/bases \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.9
creationTimestamp: null
name: clusterresourcesetbindings.clusterresourceset.cluster.x-k8s.io
spec:
group: clusterresourceset.cluster.x-k8s.io
names:
categories:
- cluster-api
kind: ClusterResourceSetBinding
listKind: ClusterResourceSetBindingList
plural: clusterresourcesetbindings
singular: clusterresourcesetbinding
scope: Namespaced
versions:
- name: v1alpha3
schema:
openAPIV3Schema:
description: ClusterResourceSetBinding lists all matching ClusterResourceSets
with the cluster it belongs to.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
clusterresourcesetmap:
additionalProperties:
description: ResourcesInClusterResourceSet keeps info on all of the
resources in a ClusterResourceSet.
properties:
resources:
additionalProperties:
description: ClusterResourceSetResourceStatus keeps status of
a resource that is applied to the cluster that ClusterResourceSetBinding
belongs to.
properties:
hash:
description: Hash is the hash of a resource's data. This can
be used to decide if a resource is changed. For "ApplyOnce"
ClusterResourceSet.spec.mode, this is no-op as that mode
do not act on change.
type: string
lastAppliedTime:
description: LastAppliedTime identifies when this resource
was last applied to the cluster.
format: date-time
type: string
successful:
description: Successful is to track if a resource is successfully
applied to the cluster or not.
type: boolean
type: object
description: 'Resources is a map of Secrets/ConfigMaps and their
ClusterResourceSetResourceStatus. The map''s key is a concatenated
string of form: <resource-type>/<resource-name>.'
type: object
type: object
description: ClusterResourceSetMap is a map of ClusterResourceSet and
its resources which is also a map.
type: object
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.9
creationTimestamp: null
name: clusterresourcesets.clusterresourceset.cluster.x-k8s.io
spec:
group: clusterresourceset.cluster.x-k8s.io
names:
categories:
- cluster-api
kind: ClusterResourceSet
listKind: ClusterResourceSetList
plural: clusterresourcesets
singular: clusterresourceset
scope: Namespaced
versions:
- name: v1alpha3
schema:
openAPIV3Schema:
description: ClusterResourceSet is the Schema for the clusterresourcesets
API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ClusterResourceSetSpec defines the desired state of ClusterResourceSet
properties:
clusterSelector:
description: Label selector for Clusters. The Clusters that are selected
by this will be the ones affected by this ClusterResourceSet. It
must match the Cluster labels.
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements.
The requirements are ANDed.
items:
description: A label selector requirement is a selector that
contains values, a key, and an operator that relates the key
and values.
properties:
key:
description: key is the label key that the selector applies
to.
type: string
operator:
description: operator represents a key's relationship to
a set of values. Valid operators are In, NotIn, Exists
and DoesNotExist.
type: string
values:
description: values is an array of string values. If the
operator is In or NotIn, the values array must be non-empty.
If the operator is Exists or DoesNotExist, the values
array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A single
{key,value} in the matchLabels map is equivalent to an element
of matchExpressions, whose key field is "key", the operator
is "In", and the values array contains only "value". The requirements
are ANDed.
type: object
type: object
mode:
description: Mode is the mode to be used during applying resources.
Defaults to ClusterResourceSetModeApplyOnce.
type: string
resources:
description: Resources is a list of Secrets/ConfigMaps where each
contains 1 or more resources to be applied to remote clusters.
items:
description: ClusterResourceSetResource specifies a resource.
properties:
kind:
description: 'Kind of the resource. Supported kinds are: Secrets
and ConfigMaps.'
type: string
name:
description: Name of the resource that is in the same namespace
with ClusterResourceSet object.
type: string
type: object
type: array
required:
- clusterSelector
type: object
status:
description: ClusterResourceSetStatus defines the observed state of ClusterResourceSet
properties:
lastUpdated:
description: LastUpdated identifies when the ClusterResourceSet last
updated.
format: date-time
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
2 changes: 2 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ resources:
- bases/cluster.x-k8s.io_machinesets.yaml
- bases/cluster.x-k8s.io_machinedeployments.yaml
- bases/exp.cluster.x-k8s.io_machinepools.yaml
- bases/clusterresourceset.cluster.x-k8s.io_clusterresourcesets.yaml
- bases/clusterresourceset.cluster.x-k8s.io_clusterresourcesetbindings.yaml
- bases/cluster.x-k8s.io_machinehealthchecks.yaml
# +kubebuilder:scaffold:crdkustomizeresource

Expand Down
28 changes: 28 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,34 @@ rules:
- patch
- update
- watch
- apiGroups:
- clusterresourceset.cluster.x-k8s.io
resources:
- '*'
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- clusterresourceset.cluster.x-k8s.io
resources:
- clusterresourcesets/status
verbs:
- get
- patch
- update
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
Expand Down
40 changes: 40 additions & 0 deletions config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,26 @@ webhooks:
resources:
- machinepools
sideEffects: None
- clientConfig:
caBundle: Cg==
service:
name: webhook-service
namespace: system
path: /mutate-exp-cluster-x-k8s-io-v1alpha3-clusterresourceset
failurePolicy: Fail
matchPolicy: Equivalent
name: default.clusterresourceset.exp.cluster.x-k8s.io
rules:
- apiGroups:
- exp.cluster.x-k8s.io
apiVersions:
- v1alpha3
operations:
- CREATE
- UPDATE
resources:
- clusterresourcesets
sideEffects: None

---
apiVersion: admissionregistration.k8s.io/v1beta1
Expand Down Expand Up @@ -254,3 +274,23 @@ webhooks:
resources:
- machinepools
sideEffects: None
- clientConfig:
caBundle: Cg==
service:
name: webhook-service
namespace: system
path: /validate-exp-cluster-x-k8s-io-v1alpha3-clusterresourceset
failurePolicy: Fail
matchPolicy: Equivalent
name: validation.clusterresourceset.exp.cluster.x-k8s.io
rules:
- apiGroups:
- exp.cluster.x-k8s.io
apiVersions:
- v1alpha3
operations:
- CREATE
- UPDATE
resources:
- clusterresourcesets
sideEffects: None
9 changes: 8 additions & 1 deletion exp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@ This subrepository holds experimental code and API types.

In short, code in this subrepository is not subject to any compatibility or deprecation promise.

TODO: Write policy around graduation and timelines.
Experiments follow a strict lifecycle: Alpha -> Beta prior to Graduation.

For more information on graduation criteria, see: [Contributing Guidelines](https://github.com/kubernetes-sigs/cluster-api/blob/aa6acaac25ef923be874d31f4834d293625abb57/CONTRIBUTING.md#experiments)

## Active Features
MachinePool (alpha)

ClusterResourceSet (alpha)
7 changes: 7 additions & 0 deletions exp/clusterresourceset/PROJECT
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
domain: cluster.x-k8s.io
repo: sigs.k8s.io/cluster-api
resources:
- group: clusterresourceset
kind: ClusterResourceSet
version: v1alpha3
version: "2"
7 changes: 7 additions & 0 deletions exp/clusterresourceset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# clusterresourceset

This subrepository holds experimental ClusterResourceSet API types.

**Warning**: Packages here are experimental and unreliable. Some may one day be promoted to the main repository, or they may be modified arbitrarily or even disappear altogether.

In short, code in this subrepository is not subject to any compatibility or deprecation promise.
Loading

0 comments on commit ae45ada

Please sign in to comment.