Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding GcpNfsVolume CR #56

Merged
merged 1 commit into from
Jan 24, 2024
Merged
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
9 changes: 9 additions & 0 deletions components/kcp/PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,13 @@ resources:
kind: IpRange
path: github.com/kyma-project/cloud-manager/components/kcp/api/cloud-resources/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: kyma-project.io
group: cloud-resources
kind: GcpNfsVolume
path: github.com/kyma-project/cloud-manager/components/kcp/api/cloud-resources/v1beta1
version: v1beta1
version: "3"
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
Copyright 2023.

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.
*/

package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// GcpNfsVolumeSpec defines the desired state of GcpNfsVolume
type GcpNfsVolumeSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of GcpNfsVolume. Edit gcpnfsvolume_types.go to remove/update
Foo string `json:"foo,omitempty"`
}

// GcpNfsVolumeStatus defines the observed state of GcpNfsVolume
type GcpNfsVolumeStatus struct {
// List of status conditions
// +optional
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// GcpNfsVolume is the Schema for the gcpnfsvolumes API
type GcpNfsVolume struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec GcpNfsVolumeSpec `json:"spec,omitempty"`
Status GcpNfsVolumeStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// GcpNfsVolumeList contains a list of GcpNfsVolume
type GcpNfsVolumeList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []GcpNfsVolume `json:"items"`
}

func init() {
SchemeBuilder.Register(&GcpNfsVolume{}, &GcpNfsVolumeList{})
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion components/kcp/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ package main
import (
"flag"
"fmt"
"os"

kcpscope "github.com/kyma-project/cloud-manager/components/kcp/pkg/kcp/scope"
scopeclient "github.com/kyma-project/cloud-manager/components/kcp/pkg/kcp/scope/client"
"os"

"github.com/kyma-project/cloud-manager/components/kcp/pkg/common/abstractions"
"github.com/kyma-project/cloud-manager/components/kcp/pkg/common/actions/focal"
Expand Down Expand Up @@ -138,6 +139,10 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "AwsNfsVolume")
os.Exit(1)
}
if err = cloudresourcescontroller.SetupGcpNfsVolumeReconciler(skrRegistry); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "GcpNfsVolume")
os.Exit(1)
}

// KCP Controllers
if err = (&cloudcontrolcontroller.ScopeReconciler{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
name: gcpnfsvolumes.cloud-resources.kyma-project.io
spec:
group: cloud-resources.kyma-project.io
names:
kind: GcpNfsVolume
listKind: GcpNfsVolumeList
plural: gcpnfsvolumes
singular: gcpnfsvolume
scope: Namespaced
versions:
- name: v1beta1
schema:
openAPIV3Schema:
description: GcpNfsVolume is the Schema for the gcpnfsvolumes 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: GcpNfsVolumeSpec defines the desired state of GcpNfsVolume
properties:
foo:
description: Foo is an example field of GcpNfsVolume. Edit gcpnfsvolume_types.go
to remove/update
type: string
type: object
status:
description: GcpNfsVolumeStatus defines the observed state of GcpNfsVolume
properties:
conditions:
description: List of status conditions
items:
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
use as an array at the field path .status.conditions. For example,
\n type FooStatus struct{ // Represents the observations of a
foo's current state. // Known .status.conditions.type are: \"Available\",
\"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge
// +listType=map // +listMapKey=type Conditions []metav1.Condition
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"
protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
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.
--- Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
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
type: object
type: object
served: true
storage: true
subresources:
status: {}
3 changes: 3 additions & 0 deletions components/kcp/config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ resources:
- bases/cloud-resources.kyma-project.io_cloudresources.yaml
- bases/cloud-resources.kyma-project.io_awsnfsvolumes.yaml
- bases/cloud-resources.kyma-project.io_ipranges.yaml
- bases/cloud-resources.kyma-project.io_gcpnfsvolumes.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patches:
Expand All @@ -21,6 +22,7 @@ patches:
#- path: patches/webhook_in_cloud-resources_cloudresources.yaml
#- path: patches/webhook_in_cloud-resources_awsnfsvolumes.yaml
#- path: patches/webhook_in_cloud-resources_ipranges.yaml
#- path: patches/webhook_in_gcpnfsvolumes.yaml
#+kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
Expand All @@ -32,6 +34,7 @@ patches:
#- path: patches/cainjection_in_cloud-resources_cloudresources.yaml
#- path: patches/cainjection_in_cloud-resources_awsnfsvolumes.yaml
#- path: patches/cainjection_in_cloud-resources_ipranges.yaml
#- path: patches/cainjection_in_gcpnfsvolumes.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# [WEBHOOK] To enable webhook, uncomment the following section
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# permissions for end users to edit gcpnfsvolumes.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: clusterrole
app.kubernetes.io/instance: gcpnfsvolume-editor-role
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: cloud-manager
app.kubernetes.io/part-of: cloud-manager
app.kubernetes.io/managed-by: kustomize
name: gcpnfsvolume-editor-role
rules:
- apiGroups:
- cloud-resources.kyma-project.io
resources:
- gcpnfsvolumes
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- cloud-resources.kyma-project.io
resources:
- gcpnfsvolumes/status
verbs:
- get
Loading
Loading