Skip to content
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
12 changes: 7 additions & 5 deletions api/core/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ const (
)

const (
LabelManagedBy = "app.kubernetes.io/managed-by"
LabelStackName = "core.stackdome.io/stack-name"
LabelStackID = "core.stackdome.io/stack-id"
LabelResourceName = "core.stackdome.io/resource-name"
LabelResourceID = "core.stackdome.io/resource-id"
LabelManagedBy = "app.kubernetes.io/managed-by"
LabelStackName = "core.stackdome.io/stack-name"
LabelStackID = "core.stackdome.io/stack-id"
LabelResourceName = "core.stackdome.io/resource-name"
LabelResourceID = "core.stackdome.io/resource-id"
LabelUsesPlatformWildcardTLS = "core.stackdome.io/uses-platform-wildcard-tls"
LabelPlatformWildcardTLSSecret = "core.stackdome.io/platform-wildcard-tls"

ManagedByStackdome = "stackdome"

Expand Down
47 changes: 47 additions & 0 deletions api/core/v1alpha1/stack_resource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ type Port struct {
FQDN string `json:"fqdn,omitempty"`
// +optional
TLS bool `json:"tls,omitempty"`
// TLSSecretRef names a pre-provisioned TLS Secret in the configured platform
// TLS namespace. Its certificate must cover FQDN. When set, the ingress uses
// a copy of this Secret instead of asking cert-manager for a certificate.
// +optional
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
TLSSecretRef string `json:"tlsSecretRef,omitempty"`
}

// +kubebuilder:validation:XValidation:rule="has(self.value) != has(self.valueFrom)",message="exactly one of value or valueFrom must be set"
Expand Down Expand Up @@ -447,6 +455,26 @@ type BuildStatus struct {
Phase string `json:"phase,omitempty"`
}

// CertManagerTLSStatus records when this resource started waiting for its
// cert-manager Certificate. The time remains set after the grace period
// expires so another reconcile does not restart the clock.
type CertManagerTLSStatus struct {
// +optional
WaitingSince *metav1.Time `json:"waitingSince,omitempty"`
}

// ReferencedTLSSecretStatus records controller state for a TLS Secret copied
// from the platform TLS namespace. It is not a user-facing condition: it scopes the
// temporary HTTPS grace period to the configured Secret reference.
type ReferencedTLSSecretStatus struct {
// Reference is the configured TLS Secret name.
Reference string `json:"reference"`
// WaitingSince is set while the source Secret or its workload replica is
// unavailable, and is cleared once the replica is ready.
// +optional
WaitingSince *metav1.Time `json:"waitingSince,omitempty"`
}

// StackResourceStatus defines the observed state of StackResource
type StackResourceStatus struct {
// The most recent generation observed by the controller.
Expand Down Expand Up @@ -478,6 +506,16 @@ type StackResourceStatus struct {
// memory) also keeps the grace window intact across operator restarts.
// +optional
PortCheck *PortCheckStatus `json:"portCheck,omitempty"`
// ReferencedTLSSecret tracks the copied Secret and the start of its
// temporary unavailable period. It is absent when no referenced TLS Secret
// is configured.
// +optional
ReferencedTLSSecret *ReferencedTLSSecretStatus `json:"referencedTLSSecret,omitempty"`
// CertManagerTLS tracks the certificate grace period independently from a
// referenced TLS Secret. It is absent when no certificate is needed or the
// certificate is ready.
// +optional
CertManagerTLS *CertManagerTLSStatus `json:"certManagerTLS,omitempty"`
// Summary is the agent's rolled-up verdict, written every pass.
// +optional
Summary *StackResourceStatusSummary `json:"summary,omitempty"`
Expand Down Expand Up @@ -582,6 +620,15 @@ type StackResource struct {
Status StackResourceStatus `json:"status,omitempty"`
}

func (w *StackResource) GetPort(port int32) *Port {
for _, p := range w.Spec.Ports {
if p.Number == port {
return &p
}
}
return nil
}

func (w *StackResource) NeedsPullSecret() bool {
if w.Spec.ImageSpec != nil && w.Spec.ImageSpec.PullAuth != nil {
return true
Expand Down
48 changes: 48 additions & 0 deletions api/core/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,15 @@ spec:
type: string
tls:
type: boolean
tlsSecretRef:
description: |-
TLSSecretRef names a pre-provisioned TLS Secret in the configured platform
TLS namespace. Its certificate must cover FQDN. When set, the ingress uses
a copy of this Secret instead of asking cert-manager for a certificate.
maxLength: 253
minLength: 1
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
required:
- name
- number
Expand Down Expand Up @@ -814,6 +823,16 @@ spec:
availableReplicas:
format: int32
type: integer
certManagerTLS:
description: |-
CertManagerTLS tracks the certificate grace period independently from a
referenced TLS Secret. It is absent when no certificate is needed or the
certificate is ready.
properties:
waitingSince:
format: date-time
type: string
type: object
conditions:
description: Conditions is a list of status conditions ths object
is in.
Expand Down Expand Up @@ -1007,6 +1026,24 @@ spec:
- revision
- status
type: object
referencedTLSSecret:
description: |-
ReferencedTLSSecret tracks the copied Secret and the start of its
temporary unavailable period. It is absent when no referenced TLS Secret
is configured.
properties:
reference:
description: Reference is the configured TLS Secret name.
type: string
waitingSince:
description: |-
WaitingSince is set while the source Secret or its workload replica is
unavailable, and is cleared once the replica is ready.
format: date-time
type: string
required:
- reference
type: object
replicas:
format: int32
type: integer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ rules:
- list
- patch
- create
- delete
- apiGroups:
- traefik.io
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ spec:
image: {{ include "stackdome-agent-standalone.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- --platform-tls-namespace={{ .Values.platformTLSNamespace }}
{{- if .Values.leaderElect }}
- --leader-elect
{{- end }}
Expand Down
1 change: 1 addition & 0 deletions charts/stackdome-agent-standalone/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ imagePullSecrets: []

replicaCount: 1
leaderElect: true
platformTLSNamespace: stackdome-control-plane

resources:
limits:
Expand Down
1 change: 1 addition & 0 deletions charts/stackdome-agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ stackdome-agent-standalone:
tag: ""
replicaCount: 1
leaderElect: true
platformTLSNamespace: stackdome-control-plane
resources:
limits:
cpu: 500m
Expand Down
4 changes: 4 additions & 0 deletions cmd/cluster-agent/cluster-agent-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func main() {
var secureMetrics bool
var enableHTTP2 bool
var imageBuildHistoryLimit int
var platformTLSNamespace string
var portCheckGrace time.Duration
var errorPagesAddr string
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
Expand All @@ -96,6 +97,8 @@ func main() {
"If set, HTTP/2 will be enabled for the metrics and webhook servers")
flag.IntVar(&imageBuildHistoryLimit, "image-build-history-limit", 5,
"Number of completed/cancelled ImageBuilds to retain per StackResource.")
flag.StringVar(&platformTLSNamespace, "platform-tls-namespace", stackresource.DefaultPlatformTLSNamespace,
"Namespace containing the platform wildcard TLS Secret.")
flag.DurationVar(&portCheckGrace, "port-check-grace", workload.DefaultPortCheckGrace,
"How long a closed-port verdict on a StackResource is re-verified before it is believed and the resource is reported failed.")
opts := zap.Options{
Expand Down Expand Up @@ -200,6 +203,7 @@ func main() {
mgr.GetClient(), mgr.GetScheme(), uncachedClient,
stackresource.StackResourceReconcilerOpts{
ImageBuildHistoryLimit: imageBuildHistoryLimit,
PlatformTLSNamespace: platformTLSNamespace,
PortVerifier: portVerifier,
PortCheckGrace: portCheckGrace,
})
Expand Down
1 change: 1 addition & 0 deletions config/deploy/01-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ rules:
- list
- patch
- create
- delete
- apiGroups:
- traefik.io
resources:
Expand Down
37 changes: 37 additions & 0 deletions config/deploy/crds/core.stackdome.io_stackresources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,15 @@ spec:
type: string
tls:
type: boolean
tlsSecretRef:
description: |-
TLSSecretRef names a pre-provisioned TLS Secret in the configured platform
TLS namespace. Its certificate must cover FQDN. When set, the ingress uses
a copy of this Secret instead of asking cert-manager for a certificate.
maxLength: 253
minLength: 1
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
required:
- name
- number
Expand Down Expand Up @@ -814,6 +823,16 @@ spec:
availableReplicas:
format: int32
type: integer
certManagerTLS:
description: |-
CertManagerTLS tracks the certificate grace period independently from a
referenced TLS Secret. It is absent when no certificate is needed or the
certificate is ready.
properties:
waitingSince:
format: date-time
type: string
type: object
conditions:
description: Conditions is a list of status conditions ths object
is in.
Expand Down Expand Up @@ -1007,6 +1026,24 @@ spec:
- revision
- status
type: object
referencedTLSSecret:
description: |-
ReferencedTLSSecret tracks the copied Secret and the start of its
temporary unavailable period. It is absent when no referenced TLS Secret
is configured.
properties:
reference:
description: Reference is the configured TLS Secret name.
type: string
waitingSince:
description: |-
WaitingSince is set while the source Secret or its workload replica is
unavailable, and is cleared once the replica is ready.
format: date-time
type: string
required:
- reference
type: object
replicas:
format: int32
type: integer
Expand Down
Loading
Loading