Skip to content

Commit 8db1e4f

Browse files
authored
Add auth CRD (#188)
* Add auth CRD * review comments
1 parent b1f1df5 commit 8db1e4f

File tree

8 files changed

+289
-1
lines changed

8 files changed

+289
-1
lines changed

.github/workflows/pr-workflow.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ jobs:
2424
- name: Helm lint (CRDs)
2525
run: |
2626
helm lint charts/qdrant-kubernetes-api
27+
helm lint charts/qdrant-kubernetes-api --set includeManagementCRDs=true
28+
helm lint charts/qdrant-kubernetes-api --set includeAuthCRDs=true
29+
helm lint charts/qdrant-kubernetes-api --set includeManagementCRDs=true --set includeAuthCRDs=true
2730
2831
- name: Run kubeconform
2932
shell: bash

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ CRDS_DIR ?= crds
1919
lint:
2020
bash -c 'files=$$(gofmt -l .) && echo $$files && [ -z "$$files" ]'
2121
helm lint $(CHART_DIR)
22+
helm lint $(CHART_DIR) --set includeManagementCRDs=true
23+
helm lint $(CHART_DIR) --set includeAuthCRDs=true
24+
helm lint $(CHART_DIR) --set includeManagementCRDs=true --set includeAuthCRDs=true
25+
helm lint $(CHART_DIR)
2226
golangci-lint run
2327

2428
.PHONY: gen
@@ -28,17 +32,24 @@ gen: manifests generate format vet ## Generate code containing DeepCopy, DeepCop
2832
manifests: controller-gen ## Generate CustomResourceDefinition objects.
2933
rm $(CHART_DIR)/templates/management-crds/*.yaml
3034
rm $(CHART_DIR)/templates/region-crds/*.yaml
35+
rm $(CHART_DIR)/templates/auth-crds/*.yaml
3136
$(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=$(CRDS_DIR)
3237
mv $(CRDS_DIR)/qdrant.io_qdrantreleases.yaml $(CHART_DIR)/templates/management-crds/
3338
cp $(CRDS_DIR)/qdrant*.yaml $(CHART_DIR)/templates/region-crds/
39+
mv $(CRDS_DIR)/auth.qdrant.io*.yaml $(CHART_DIR)/templates/auth-crds/
3440
for file in $(CHART_DIR)/templates/management-crds/*.yaml; do \
3541
echo "{{ if .Values.includeManagementCRDs }}" | cat - $$file > temp && mv temp $$file; \
3642
echo "{{ end }}" >> $$file; \
3743
done
38-
for file in $(CHART_DIR)/templates/region-crds/*.yaml; do \
44+
for file in $(CHART_DIR)/templates/region-crds/qdrant*.yaml; do \
3945
echo "{{ if .Values.includeRegionCRDs }}" | cat - $$file > temp && mv temp $$file; \
4046
echo "{{ end }}" >> $$file; \
4147
done
48+
# We only want to deploy API key CRD to regional clusters
49+
for file in $(CHART_DIR)/templates/auth-crds/auth.qdrant.io*.yaml; do \
50+
echo "{{ if .Values.includeAuthCRDs }}" | cat - $$file > temp && mv temp $$file; \
51+
echo "{{ end }}" >> $$file; \
52+
done
4253
helm lint $(CHART_DIR)
4354

4455
.PHONY: generate
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package v1alpha1
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
)
6+
7+
// +genclient
8+
// +kubebuilder:object:root=true
9+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
10+
11+
// APIAuthentication is a configuration for authenticating against Qdrant clusters.
12+
type APIAuthentication struct {
13+
metav1.TypeMeta `json:",inline"`
14+
// Standard object's metadata.
15+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
16+
// +optional
17+
metav1.ObjectMeta `json:"metadata,omitempty"`
18+
19+
Spec APIAuthenticationSpec `json:"spec"`
20+
}
21+
22+
// APIAuthenticationSpec describes the configuration for authenticating against Qdrant clusters.
23+
type APIAuthenticationSpec struct {
24+
// +kubebuilder:validation:MinLength=128
25+
// +kubebuilder:validation:MaxLength=128
26+
// +optional
27+
// SHA512 hash of an API key.
28+
SHA512 *string `json:"sha512,omitempty"`
29+
30+
// +listType=set
31+
// List of cluster IDs for which the API key is valid
32+
ClusterIDs []string `json:"clusterIDs"`
33+
}
34+
35+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
36+
37+
// APIAuthenticationList is the whole list of all APIAuthentication objects.
38+
type APIAuthenticationList struct {
39+
metav1.TypeMeta `json:",inline"`
40+
// Standard list metadata.
41+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
42+
// +optional
43+
metav1.ListMeta `json:"metadata,omitempty"`
44+
45+
// List of APIAuthentication objects
46+
Items []APIAuthentication `json:"items"`
47+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Package v1alpha1 contains API Schema definitions for the qdrant.io v1alpha1 API group
2+
// +kubebuilder:object:generate=true
3+
// +groupName=auth.qdrant.io
4+
package v1alpha1
5+
6+
import (
7+
"k8s.io/apimachinery/pkg/runtime/schema"
8+
"sigs.k8s.io/controller-runtime/pkg/scheme"
9+
)
10+
11+
var (
12+
// GroupVersion is group version used to register these objects
13+
GroupVersion = schema.GroupVersion{Group: "auth.qdrant.io", Version: "v1alpha1"}
14+
15+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
16+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
17+
18+
// AddToScheme adds the types in this group-version to the given scheme.
19+
AddToScheme = SchemeBuilder.AddToScheme
20+
)

api/auth/v1alpha1/zz_generated.deepcopy.go

Lines changed: 92 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{{ if .Values.includeAuthCRDs }}
2+
---
3+
apiVersion: apiextensions.k8s.io/v1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
controller-gen.kubebuilder.io/version: v0.19.0
8+
name: apiauthentications.auth.qdrant.io
9+
spec:
10+
group: auth.qdrant.io
11+
names:
12+
kind: APIAuthentication
13+
listKind: APIAuthenticationList
14+
plural: apiauthentications
15+
singular: apiauthentication
16+
scope: Namespaced
17+
versions:
18+
- name: v1alpha1
19+
schema:
20+
openAPIV3Schema:
21+
description: APIAuthentication is a configuration for authenticating against
22+
Qdrant clusters.
23+
properties:
24+
apiVersion:
25+
description: |-
26+
APIVersion defines the versioned schema of this representation of an object.
27+
Servers should convert recognized schemas to the latest internal value, and
28+
may reject unrecognized values.
29+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
30+
type: string
31+
kind:
32+
description: |-
33+
Kind is a string value representing the REST resource this object represents.
34+
Servers may infer this from the endpoint the client submits requests to.
35+
Cannot be updated.
36+
In CamelCase.
37+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
38+
type: string
39+
metadata:
40+
type: object
41+
spec:
42+
description: APIAuthenticationSpec describes the configuration for authenticating
43+
against Qdrant clusters.
44+
properties:
45+
clusterIDs:
46+
description: List of cluster IDs for which the API key is valid
47+
items:
48+
type: string
49+
type: array
50+
x-kubernetes-list-type: set
51+
sha512:
52+
description: SHA512 hash of an API key.
53+
maxLength: 128
54+
minLength: 128
55+
type: string
56+
required:
57+
- clusterIDs
58+
type: object
59+
required:
60+
- spec
61+
type: object
62+
served: true
63+
storage: true
64+
{{ end }}

charts/qdrant-kubernetes-api/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
includeManagementCRDs: false
33
# Include region-crds in the deployment
44
includeRegionCRDs: true
5+
# Include auth.qdrant.io API key CRD in the deployment
6+
includeAuthCRDs: false

docs/api.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,58 @@
11
# API Reference
22

33
## Packages
4+
- [auth.qdrant.io/v1alpha1](#authqdrantiov1alpha1)
45
- [qdrant.io/v1](#qdrantiov1)
56

67

8+
## auth.qdrant.io/v1alpha1
9+
10+
Package v1alpha1 contains API Schema definitions for the qdrant.io v1alpha1 API group
11+
12+
### Resource Types
13+
- [APIAuthentication](#apiauthentication)
14+
15+
16+
17+
#### APIAuthentication
18+
19+
20+
21+
APIAuthentication is a configuration for authenticating against Qdrant clusters.
22+
23+
24+
25+
_Appears in:_
26+
- [APIAuthenticationList](#apiauthenticationlist)
27+
28+
| Field | Description | Default | Validation |
29+
| --- | --- | --- | --- |
30+
| `apiVersion` _string_ | `auth.qdrant.io/v1alpha1` | | |
31+
| `kind` _string_ | `APIAuthentication` | | |
32+
| `metadata` _[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#objectmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | | |
33+
| `spec` _[APIAuthenticationSpec](#apiauthenticationspec)_ | | | |
34+
35+
36+
37+
38+
#### APIAuthenticationSpec
39+
40+
41+
42+
APIAuthenticationSpec describes the configuration for authenticating against Qdrant clusters.
43+
44+
45+
46+
_Appears in:_
47+
- [APIAuthentication](#apiauthentication)
48+
49+
| Field | Description | Default | Validation |
50+
| --- | --- | --- | --- |
51+
| `sha512` _string_ | SHA512 hash of an API key. | | MaxLength: 128 <br />MinLength: 128 <br /> |
52+
| `clusterIDs` _string array_ | List of cluster IDs for which the API key is valid | | |
53+
54+
55+
756
## qdrant.io/v1
857

958
Package v1 contains API Schema definitions for the qdrant.io v1 API group

0 commit comments

Comments
 (0)