Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"github.com/kcp-dev/kcp-operator/internal/controller/kubeconfig"
"github.com/kcp-dev/kcp-operator/internal/controller/rootshard"
"github.com/kcp-dev/kcp-operator/internal/controller/shard"
"github.com/kcp-dev/kcp-operator/internal/controller/workspaceobject"
"github.com/kcp-dev/kcp-operator/internal/reconciling"
operatorv1alpha1 "github.com/kcp-dev/kcp-operator/sdk/apis/operator/v1alpha1"
)
Expand Down Expand Up @@ -188,6 +189,13 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Kubeconfig")
os.Exit(1)
}
if err = (&workspaceobject.WorkspaceObjectReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "WorkspaceObject")
os.Exit(1)
}
// +kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
Expand Down
171 changes: 171 additions & 0 deletions config/crd/bases/operator.kcp.io_workspaceobjects.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.1
name: workspaceobjects.operator.kcp.io
spec:
group: operator.kcp.io
names:
kind: WorkspaceObject
listKind: WorkspaceObjectList
plural: workspaceobjects
singular: workspaceobject
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.rootShard.ref.name
name: RootShard
type: string
- jsonPath: .status.conditions[?(@.type=='Available')].reason
name: Status
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
description: WorkspaceObject is the Schema for the WorkspaceObjects 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: WorkspaceObjectSpec defines the desired state of WorkspaceObject
properties:
managementPolicies:
default:
- '*'
description: |-
ManagementPolicies specify the operations that should be executed by the
operator. By default, the operator manages creation, update and deletion
of objects.
items:
type: string
type: array
manifest:
description: Manifest is the desired state of the object in the workspace.
x-kubernetes-preserve-unknown-fields: true
rootShard:
description: |-
RootShard is a reference to the root shard that holds the workspace in
which the manifest should be applied.
properties:
ref:
description: Reference references a local RootShard object.
properties:
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
type: object
x-kubernetes-map-type: atomic
type: object
workspace:
description: Workspace specifies in which workspace the manifest should
be applied.
properties:
path:
description: Path is the path of the workspace inside kcp.
type: string
required:
- path
type: object
required:
- managementPolicies
- manifest
- rootShard
- workspace
type: object
status:
description: WorkspaceObjectStatus defines the observed state of WorkspaceObject
properties:
conditions:
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
properties:
lastTransitionTime:
description: |-
lastTransitionTime is the last time the condition transitioned from one status to another.
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: |-
message is a human readable message indicating details about the transition.
This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: |-
observedGeneration represents the .metadata.generation that the condition was set based upon.
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
with respect to the current state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: |-
reason contains a programmatic identifier indicating the reason for the condition's last transition.
Producers of specific condition types may define expected values and meanings for this field,
and whether the values are considered a guaranteed API.
The value should be a CamelCase string.
This field may not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: type of condition in CamelCase or in foo.example.com/CamelCase.
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
manifest:
description: Manifest is the actual state of the object in the workspace.
x-kubernetes-preserve-unknown-fields: true
type: object
type: object
served: true
storage: true
subresources:
status: {}
1 change: 1 addition & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ resources:
- bases/operator.kcp.io_shards.yaml
- bases/operator.kcp.io_cacheservers.yaml
- bases/operator.kcp.io_kubeconfigs.yaml
- bases/operator.kcp.io_workspaceobjects.yaml
# +kubebuilder:scaffold:crdkustomizeresource

patches: []
Expand Down
11 changes: 11 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ rules:
- kubeconfigs/finalizers
- rootshards/finalizers
- shards/finalizers
- workspaceobjects/finalizers
verbs:
- update
- apiGroups:
Expand All @@ -74,6 +75,7 @@ rules:
- kubeconfigs/status
- rootshards/status
- shards/status
- workspaceobjects/status
verbs:
- get
- patch
Expand All @@ -84,9 +86,18 @@ rules:
- kubeconfigs
- rootshards
- shards
- workspaceobjects
verbs:
- get
- list
- patch
- update
- watch
- apiGroups:
- operator.kcp.io
resources:
- workspaces
verbs:
- get
- list
- watch
21 changes: 21 additions & 0 deletions config/samples/operator.kcp.io_v1alpha1_workspaceobject.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: operator.kcp.io/v1alpha1
kind: WorkspaceObject
metadata:
labels:
app.kubernetes.io/name: kcp-operator
app.kubernetes.io/managed-by: kustomize
name: object.workspace.custom
namespace: kcp
spec:
rootShard:
ref:
# name: shard-sample
name: root
workspace:
path: root
manifest:
apiVersion: tenancy.kcp.io/v1alpha1
kind: Workspace
metadata:
name: test
spec: {}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
go.uber.org/zap v1.27.0
k8c.io/reconciler v0.5.0
k8s.io/api v0.32.0
k8s.io/apiextensions-apiserver v0.32.0
k8s.io/apimachinery v0.32.0
k8s.io/client-go v0.32.0
k8s.io/code-generator v0.32.0
Expand Down Expand Up @@ -105,7 +106,6 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.32.0 // indirect
k8s.io/apiserver v0.32.0 // indirect
k8s.io/component-base v0.32.0 // indirect
k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9 // indirect
Expand Down
Loading