Skip to content

Commit a09a9d6

Browse files
authored
Automated cherry pick of #760: feat: add SecretProviderClass and (#765)
* feat: add SecretProviderClass and SecretProviderClassPodStatus v1 Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com> * test: update yamls to use v1 api version Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com> * test: use api version based on kubectl api-resources output Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
1 parent 3049a64 commit a09a9d6

File tree

77 files changed

+3045
-390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+3045
-390
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ EKS_CLUSTER_NAME := integ-cluster-$(BUILD_TIMESTAMP_W_SEC)
114114
AWS_REGION := us-west-2
115115

116116
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
117-
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
117+
CRD_OPTIONS ?= "crd:crdVersions=v1"
118118

119119
## --------------------------------------
120120
## Validate golang version
@@ -488,7 +488,8 @@ e2e-aws:
488488
.PHONY: manifests
489489
manifests: $(CONTROLLER_GEN) $(KUSTOMIZE)
490490
# Generate the base CRD/RBAC
491-
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=secretproviderclasses-role paths="./apis/..." paths="./controllers" output:crd:artifacts:config=config/crd/bases
491+
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=secretproviderclasses-role object:headerFile=./hack/boilerplate.go.txt paths="./apis/..." \
492+
paths="./apis/..." paths="./controllers" output:crd:artifacts:config=config/crd/bases
492493
cp config/crd/bases/* manifest_staging/charts/secrets-store-csi-driver/crds
493494
cp config/crd/bases/* manifest_staging/deploy/
494495

apis/v1/doc.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
Copyright 2021 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package v1 contains API Schema definitions for the secrets-store v1 API group
18+
// +kubebuilder:object:generate=true
19+
// +k8s:deepcopy-gen=package,register
20+
// +groupName=secrets-store.csi.x-k8s.io
21+
package v1

apis/v1/secretproviderclass_types.go

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// Provider enum for all the provider names
24+
type Provider string
25+
26+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
27+
28+
// SecretObjectData defines the desired state of synced K8s secret object data
29+
type SecretObjectData struct {
30+
// name of the object to sync
31+
ObjectName string `json:"objectName,omitempty"`
32+
// data field to populate
33+
Key string `json:"key,omitempty"`
34+
}
35+
36+
// SecretObject defines the desired state of synced K8s secret objects
37+
type SecretObject struct {
38+
// name of the K8s secret object
39+
SecretName string `json:"secretName,omitempty"`
40+
// type of K8s secret object
41+
Type string `json:"type,omitempty"`
42+
// labels of K8s secret object
43+
Labels map[string]string `json:"labels,omitempty"`
44+
// annotations of k8s secret object
45+
Annotations map[string]string `json:"annotations,omitempty"`
46+
Data []*SecretObjectData `json:"data,omitempty"`
47+
}
48+
49+
// SecretProviderClassSpec defines the desired state of SecretProviderClass
50+
type SecretProviderClassSpec struct {
51+
// Configuration for provider name
52+
Provider Provider `json:"provider,omitempty"`
53+
// Configuration for specific provider
54+
Parameters map[string]string `json:"parameters,omitempty"`
55+
SecretObjects []*SecretObject `json:"secretObjects,omitempty"`
56+
}
57+
58+
// ByPodStatus defines the state of SecretProviderClass as seen by
59+
// an individual controller
60+
type ByPodStatus struct {
61+
// id of the pod that wrote the status
62+
ID string `json:"id,omitempty"`
63+
// namespace of the pod that wrote the status
64+
Namespace string `json:"namespace,omitempty"`
65+
}
66+
67+
// SecretProviderClassStatus defines the observed state of SecretProviderClass
68+
type SecretProviderClassStatus struct {
69+
ByPod []*ByPodStatus `json:"byPod,omitempty"`
70+
}
71+
72+
// +kubebuilder:object:root=true
73+
// +kubebuilder:storageversion
74+
// +genclient
75+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
76+
77+
// SecretProviderClass is the Schema for the secretproviderclasses API
78+
type SecretProviderClass struct {
79+
metav1.TypeMeta `json:",inline"`
80+
metav1.ObjectMeta `json:"metadata,omitempty"`
81+
82+
Spec SecretProviderClassSpec `json:"spec,omitempty"`
83+
Status SecretProviderClassStatus `json:"status,omitempty"`
84+
}
85+
86+
// +kubebuilder:object:root=true
87+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
88+
89+
// SecretProviderClassList contains a list of SecretProviderClass
90+
type SecretProviderClassList struct {
91+
metav1.TypeMeta `json:",inline"`
92+
metav1.ListMeta `json:"metadata,omitempty"`
93+
Items []SecretProviderClass `json:"items"`
94+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
20+
21+
const (
22+
// InternalNodeLabel used for setting the node name spc pod status belongs to
23+
InternalNodeLabel = "internal.secrets-store.csi.k8s.io/node-name"
24+
)
25+
26+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
27+
28+
// SecretProviderClassPodStatusStatus defines the observed state of SecretProviderClassPodStatus
29+
type SecretProviderClassPodStatusStatus struct {
30+
PodName string `json:"podName,omitempty"`
31+
SecretProviderClassName string `json:"secretProviderClassName,omitempty"`
32+
Mounted bool `json:"mounted,omitempty"`
33+
TargetPath string `json:"targetPath,omitempty"`
34+
Objects []SecretProviderClassObject `json:"objects,omitempty"`
35+
}
36+
37+
// SecretProviderClassObject defines the object fetched from external secrets store
38+
type SecretProviderClassObject struct {
39+
ID string `json:"id,omitempty"`
40+
Version string `json:"version,omitempty"`
41+
}
42+
43+
// +kubebuilder:object:root=true
44+
// +kubebuilder:storageversion
45+
// +genclient
46+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
47+
48+
// SecretProviderClassPodStatus is the Schema for the secretproviderclassespodstatus API
49+
type SecretProviderClassPodStatus struct {
50+
metav1.TypeMeta `json:",inline"`
51+
metav1.ObjectMeta `json:"metadata,omitempty"`
52+
53+
Status SecretProviderClassPodStatusStatus `json:"status,omitempty"`
54+
}
55+
56+
// +kubebuilder:object:root=true
57+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
58+
59+
// SecretProviderClassPodStatusList contains a list of SecretProviderClassPodStatus
60+
type SecretProviderClassPodStatusList struct {
61+
metav1.TypeMeta `json:",inline"`
62+
metav1.ListMeta `json:"metadata,omitempty"`
63+
Items []SecretProviderClassPodStatus `json:"items"`
64+
}

0 commit comments

Comments
 (0)