Skip to content

Commit 878a701

Browse files
committed
add: anntation
1 parent aa00895 commit 878a701

7 files changed

Lines changed: 38 additions & 12 deletions

File tree

api/v1alpha1/connector_types.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,12 @@ type ConnectorSpec struct {
6060
// ResourceMetadata contains metadata for the resource
6161
type ResourceMetadata struct {
6262
// +optional
63-
// Labels to apply to deployments
63+
// Labels to apply to deployments and pods
6464
Labels map[string]string `json:"labels,omitempty"`
65+
66+
// +optional
67+
// Annotations to apply to pods
68+
Annotations map[string]string `json:"annotations,omitempty"`
6569
}
6670

6771
type ConnectorSpecSpec struct {

api/v1alpha1/controlserver_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ type TLSConfig struct {
164164
// AcmePath for storing ACME generated artifacts
165165
AcmePath string `json:"acmePath,omitempty"`
166166

167-
// +kubebuilder:default=true
167+
// +kubebuilder:default=false
168168
// +optional
169169
// ForceHTTPS redirects HTTP requests to HTTPS when TLS is enabled
170170
ForceHTTPS bool `json:"forceHttps,omitempty"`

api/v1alpha1/zz_generated.deepcopy.go

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

config/crd/bases/kodiak.mnicloud.jp_connectors.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,15 @@ spec:
8181
metadata:
8282
description: Metadata for the resource
8383
properties:
84+
annotations:
85+
additionalProperties:
86+
type: string
87+
description: Annotations to apply to pods
88+
type: object
8489
labels:
8590
additionalProperties:
8691
type: string
87-
description: Labels to apply to deployments
92+
description: Labels to apply to deployments and pods
8893
type: object
8994
type: object
9095
spec:

config/crd/bases/kodiak.mnicloud.jp_controlservers.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ spec:
294294
description: Disable TLS
295295
type: boolean
296296
forceHttps:
297-
default: true
297+
default: false
298298
description: ForceHTTPS redirects HTTP requests to HTTPS when
299299
TLS is enabled
300300
type: boolean

internal/controller/connector_controller.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func (r *ConnectorReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
155155
logger.Error(err, "Failed to resolve auth key for connector")
156156
return ctrl.Result{}, err
157157
}
158-
if authKeyResult.Requeue {
158+
if authKeyResult.Requeue || authKeyResult.RequeueAfter != 0 {
159159
return authKeyResult, nil
160160
}
161161
if resolvedAuth == nil {
@@ -647,6 +647,15 @@ func (r *ConnectorReconciler) deploymentForConnector(cr *v1alpha1.Connector, log
647647
}
648648
}
649649

650+
// Get annotations for pods
651+
var annotations map[string]string
652+
if cr.Spec.Metadata != nil && cr.Spec.Metadata.Annotations != nil {
653+
annotations = make(map[string]string)
654+
for k, v := range cr.Spec.Metadata.Annotations {
655+
annotations[k] = v
656+
}
657+
}
658+
650659
deploy := &appsv1.Deployment{
651660
ObjectMeta: metav1.ObjectMeta{
652661
Name: cr.Name + deploymentNameSuffix,
@@ -659,7 +668,8 @@ func (r *ConnectorReconciler) deploymentForConnector(cr *v1alpha1.Connector, log
659668
},
660669
Template: corev1.PodTemplateSpec{
661670
ObjectMeta: metav1.ObjectMeta{
662-
Labels: labels,
671+
Labels: labels,
672+
Annotations: annotations,
663673
},
664674
Spec: corev1.PodSpec{
665675
ServiceAccountName: "tailscale-connector",

internal/controller/controlserver_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -944,16 +944,16 @@ func computeControlServerAddresses(resource *kodiakv1alpha1.ControlServer) (stri
944944
}
945945

946946
func sanitizePublicAddr(candidate string, tlsConfig *kodiakv1alpha1.TLSConfig, namespace, svcName string, listenPort int32) string {
947-
if candidate == "" {
948-
host := fmt.Sprintf("%s.%s.svc.cluster.local", svcName, namespace)
949-
return fmt.Sprintf("%s:%d", host, listenPort)
950-
}
951-
952947
scheme := schemeHTTPS
953948
if tlsConfig != nil && tlsConfig.Disable {
954949
scheme = schemeHTTP
955950
}
956951

952+
if candidate == "" {
953+
host := fmt.Sprintf("%s.%s.svc.cluster.local", svcName, namespace)
954+
return fmt.Sprintf("%s://%s:%d", scheme, host, listenPort)
955+
}
956+
957957
addr := trimScheme(candidate)
958958

959959
if _, _, err := net.SplitHostPort(addr); err != nil {
@@ -964,7 +964,7 @@ func sanitizePublicAddr(candidate string, tlsConfig *kodiakv1alpha1.TLSConfig, n
964964
addr = fmt.Sprintf("%s:%d", addr, defaultPort)
965965
}
966966

967-
return addr
967+
return fmt.Sprintf("%s://%s", scheme, addr)
968968
}
969969

970970
func trimScheme(value string) string {

0 commit comments

Comments
 (0)