Skip to content

Commit 296b021

Browse files
committed
WIP ServiceTransport CR to connect to services
New ServiceTransport custom resource similar to the TransportURL CR. This exposes configuration snippets that are necessary to connect to services like memcached or redis, based on how those services are instantiated (e.g. TLS, authentication). Jira: OSPRH-5283
1 parent ba41f87 commit 296b021

File tree

10 files changed

+792
-0
lines changed

10 files changed

+792
-0
lines changed

PROJECT

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,17 @@ resources:
8989
defaulting: true
9090
validation: true
9191
webhookVersion: v1
92+
- api:
93+
crdVersion: v1
94+
namespaced: true
95+
controller: true
96+
domain: openstack.org
97+
group: network
98+
kind: ServiceTransport
99+
path: github.com/openstack-k8s-operators/infra-operator/apis/memcached/v1beta1
100+
version: v1beta1
101+
webhooks:
102+
defaulting: true
103+
validation: true
104+
webhookVersion: v1
92105
version: "3"
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.11.1
7+
creationTimestamp: null
8+
name: servicetransports.memcached.openstack.org
9+
spec:
10+
group: memcached.openstack.org
11+
names:
12+
kind: ServiceTransport
13+
listKind: ServiceTransportList
14+
plural: servicetransports
15+
singular: servicetransport
16+
scope: Namespaced
17+
versions:
18+
- additionalPrinterColumns:
19+
- description: Status
20+
jsonPath: .status.conditions[0].status
21+
name: Status
22+
type: string
23+
- description: Message
24+
jsonPath: .status.conditions[0].message
25+
name: Message
26+
type: string
27+
name: v1beta1
28+
schema:
29+
openAPIV3Schema:
30+
description: ServiceTransport is the Schema for the servicetransports API
31+
properties:
32+
apiVersion:
33+
description: 'APIVersion defines the versioned schema of this representation
34+
of an object. Servers should convert recognized schemas to the latest
35+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
36+
type: string
37+
kind:
38+
description: 'Kind is a string value representing the REST resource this
39+
object represents. Servers may infer this from the endpoint the client
40+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
41+
type: string
42+
metadata:
43+
type: object
44+
spec:
45+
description: ServiceTransportSpec defines the desired state of ServiceTransport
46+
properties:
47+
serviceName:
48+
description: Name of the service targeted by the transport
49+
type: string
50+
required:
51+
- serviceName
52+
type: object
53+
status:
54+
description: ServiceTransportStatus defines the observed state of ServiceTransport
55+
properties:
56+
conditions:
57+
description: Conditions
58+
items:
59+
description: Condition defines an observation of a API resource
60+
operational state.
61+
properties:
62+
lastTransitionTime:
63+
description: Last time the condition transitioned from one status
64+
to another. This should be when the underlying condition changed.
65+
If that is not known, then using the time when the API field
66+
changed is acceptable.
67+
format: date-time
68+
type: string
69+
message:
70+
description: A human readable message indicating details about
71+
the transition.
72+
type: string
73+
reason:
74+
description: The reason for the condition's last transition
75+
in CamelCase.
76+
type: string
77+
severity:
78+
description: Severity provides a classification of Reason code,
79+
so the current situation is immediately understandable and
80+
could act accordingly. It is meant for situations where Status=False
81+
and it should be indicated if it is just informational, warning
82+
(next reconciliation might fix it) or an error (e.g. DB create
83+
issue and no actions to automatically resolve the issue can/should
84+
be done). For conditions where Status=Unknown or Status=True
85+
the Severity should be SeverityNone.
86+
type: string
87+
status:
88+
description: Status of the condition, one of True, False, Unknown.
89+
type: string
90+
type:
91+
description: Type of condition in CamelCase.
92+
type: string
93+
required:
94+
- lastTransitionTime
95+
- status
96+
- type
97+
type: object
98+
type: array
99+
secretName:
100+
description: SecretName - name of the secret containing the service
101+
transport URL
102+
type: string
103+
type: object
104+
type: object
105+
served: true
106+
storage: true
107+
subresources:
108+
status: {}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
package v1beta1
17+
18+
import (
19+
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
20+
)
21+
22+
// ServiceTransport Condition Types used by API objects.
23+
const (
24+
// ServiceTransportReadyCondition Status=True condition which indicates if ServiceTransport is configured and operational
25+
ServiceTransportReadyCondition condition.Type = "ServiceTransportReady"
26+
)
27+
28+
// ServiceTransport Reasons used by API objects.
29+
const ()
30+
31+
// Common Messages used by API objects.
32+
const (
33+
//
34+
// ServiceTransportReady condition messages
35+
//
36+
37+
// ServiceTransportReadyErrorMessage
38+
ServiceTransportReadyErrorMessage = "ServiceTransport error occured %s"
39+
40+
// ServiceTransportReadyInitMessage
41+
ServiceTransportReadyInitMessage = "ServiceTransport not configured"
42+
43+
// ServiceTransportReadyMessage
44+
ServiceTransportReadyMessage = "ServiceTransport completed"
45+
46+
// ServiceTransportInProgressMessage
47+
ServiceTransportInProgressMessage = "ServiceTransport in progress"
48+
)
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
Copyright 2022.
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 v1beta1
18+
19+
import (
20+
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
)
23+
24+
// ServiceTransportSpec defines the desired state of ServiceTransport
25+
type ServiceTransportSpec struct {
26+
// +kubebuilder:validation:Required
27+
// Name of the service targeted by the transport
28+
ServiceName string `json:"serviceName"`
29+
}
30+
31+
// ServiceTransportStatus defines the observed state of ServiceTransport
32+
type ServiceTransportStatus struct {
33+
34+
// Conditions
35+
Conditions condition.Conditions `json:"conditions,omitempty" optional:"true"`
36+
37+
// SecretName - name of the secret containing the service transport URL
38+
SecretName string `json:"secretName,omitempty"`
39+
}
40+
41+
//+kubebuilder:object:root=true
42+
//+kubebuilder:subresource:status
43+
//+kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[0].status",description="Status"
44+
//+kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[0].message",description="Message"
45+
46+
// ServiceTransport is the Schema for the servicetransports API
47+
type ServiceTransport struct {
48+
metav1.TypeMeta `json:",inline"`
49+
metav1.ObjectMeta `json:"metadata,omitempty"`
50+
51+
Spec ServiceTransportSpec `json:"spec,omitempty"`
52+
Status ServiceTransportStatus `json:"status,omitempty"`
53+
}
54+
55+
//+kubebuilder:object:root=true
56+
57+
// ServiceTransportList contains a list of ServiceTransport
58+
type ServiceTransportList struct {
59+
metav1.TypeMeta `json:",inline"`
60+
metav1.ListMeta `json:"metadata,omitempty"`
61+
Items []ServiceTransport `json:"items"`
62+
}
63+
64+
func init() {
65+
SchemeBuilder.Register(&ServiceTransport{}, &ServiceTransportList{})
66+
}
67+
68+
// IsReady - returns true if service is ready to serve requests
69+
func (instance ServiceTransport) IsReady() bool {
70+
return instance.Status.Conditions.IsTrue(ServiceTransportReadyCondition)
71+
}

apis/memcached/v1beta1/zz_generated.deepcopy.go

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)