Skip to content

Commit b7643ca

Browse files
committed
TLS configurable option for PQC
Signed-off-by: akhil nittala <nakhil@redhat.com>
1 parent fee011b commit b7643ca

12 files changed

Lines changed: 798 additions & 218 deletions

File tree

Dockerfile

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
11
# Build the manager binary
2-
FROM golang:1.25 as builder
2+
FROM --platform=linux/amd64 golang:1.25 AS builder
33

44
WORKDIR /workspace
5+
6+
COPY argocd-operator /workspace/argocd-operator
7+
58
# Copy the Go Modules manifests
69
COPY go.mod go.mod
710
COPY go.sum go.sum
8-
# cache deps before building and copying source so that we don't need to re-download as much
9-
# and so that source changes don't invalidate our downloaded layer
11+
12+
# Cache dependencies
1013
RUN go mod download
1114

12-
# Copy the go source
15+
# Copy the Go source
1316
COPY cmd/main.go cmd/main.go
1417
COPY api/ api/
1518
COPY controllers/ controllers/
1619
COPY common/ common/
1720
COPY version/ version/
1821

19-
# Build - Use TARGETARCH to build for the correct architecture
20-
ARG TARGETARCH
21-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o manager ./cmd/main.go
22+
# Build explicitly for linux/amd64
23+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager ./cmd/main.go
24+
25+
# Use distroless as minimal base image
26+
FROM --platform=linux/amd64 gcr.io/distroless/static:nonroot
2227

23-
# Use distroless as minimal base image to package the manager binary
24-
# Refer to https://github.com/GoogleContainerTools/distroless for more details
25-
FROM gcr.io/distroless/static:nonroot
2628
WORKDIR /
29+
2730
COPY --from=builder /workspace/manager /usr/local/bin/manager
2831

29-
# install redis artifacts
32+
# Install redis artifacts
3033
COPY build/redis /var/lib/redis
3134

3235
USER 65532:65532
3336

34-
ENTRYPOINT ["/usr/local/bin/manager"]
37+
ENTRYPOINT ["/usr/local/bin/manager"]

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ run: manifests generate fmt vet ## Run a controller from your host.
183183
CLUSTER_SCOPED_ARGO_ROLLOUTS_NAMESPACES=argo-rollouts,test-rom-ns-1,rom-ns-1,openshift-gitops ARGOCD_CLUSTER_CONFIG_NAMESPACES="openshift-gitops, argocd-e2e-cluster-config, argocd-test-impersonation-1-046, argocd-agent-principal-1-051, argocd-agent-agent-1-052, appset-argocd, appset-old-ns, appset-new-ns, ns-hosting-principal, ns-hosting-managed-agent, ns-hosting-autonomous-agent, appset-argocd-clusterrole" REDIS_CONFIG_PATH="build/redis" go run ./cmd/main.go
184184

185185
.PHONY: docker-build
186-
docker-build: test ## Build container image with the manager.
187-
$(CONTAINER_RUNTIME) build -t ${IMG} .
186+
docker-build: ## Build container image with the manager.
187+
$(CONTAINER_RUNTIME) build --platform=linux/amd64 -t ${IMG} .
188188

189189
.PHONY: docker-push
190190
docker-push: ## Push container image with the manager.

cmd/main.go

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package main
1818

1919
import (
20+
"context"
2021
"crypto/tls"
2122
"flag"
2223
"fmt"
@@ -46,6 +47,7 @@ import (
4647
oauthv1 "github.com/openshift/api/oauth/v1"
4748
routev1 "github.com/openshift/api/route/v1"
4849
templatev1 "github.com/openshift/api/template/v1"
50+
tlspkg "github.com/openshift/controller-runtime-common/pkg/tls"
4951
operatorsv1 "github.com/operator-framework/api/pkg/operators/v1"
5052
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
5153
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
@@ -131,6 +133,8 @@ func main() {
131133
flag.Parse()
132134

133135
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
136+
ctx, cancel := context.WithCancel(ctrl.SetupSignalHandler())
137+
defer cancel()
134138

135139
if err := util.InspectCluster(); err != nil {
136140
setupLog.Info("unable to inspect cluster")
@@ -142,15 +146,40 @@ func main() {
142146
}
143147
c.NextProtos = []string{"http/1.1"}
144148
}
149+
150+
restConfig := ctrl.GetConfigOrDie()
151+
// Register config.openshift.io APIs before creating bootstrap client
152+
utilruntime.Must(configv1.Install(scheme))
153+
bootstrapClient, err := crclient.New(restConfig, crclient.Options{
154+
Scheme: scheme,
155+
})
156+
if err != nil {
157+
setupLog.Error(err, "unable to create bootstrap client")
158+
os.Exit(1)
159+
}
160+
var profile configv1.TLSProfileSpec
161+
profile, err = tlspkg.FetchAPIServerTLSProfile(ctx, bootstrapClient)
162+
if err != nil {
163+
setupLog.Error(err, "unable to fetch cluster TLS profile")
164+
os.Exit(1)
165+
}
166+
tlsOpts := []func(*tls.Config){disableHTTP2}
167+
tlsConfigFn, unsupported := tlspkg.NewTLSConfigFromProfile(profile)
168+
if len(unsupported) > 0 {
169+
setupLog.Info("TLS profile contains unsupported Go cipher suites", "ciphers", unsupported)
170+
}
171+
172+
tlsOpts = append(tlsOpts, tlsConfigFn)
173+
145174
webhookServerOptions := webhook.Options{
146-
TLSOpts: []func(config *tls.Config){disableHTTP2},
175+
TLSOpts: tlsOpts,
147176
Port: 9443,
148177
}
149178
webhookServer := webhook.NewServer(webhookServerOptions)
150179

151180
metricsServerOptions := metricsserver.Options{
152181
BindAddress: metricsAddr,
153-
TLSOpts: []func(*tls.Config){disableHTTP2},
182+
TLSOpts: tlsOpts,
154183
FilterProvider: filters.WithAuthenticationAndAuthorization,
155184
}
156185

@@ -180,15 +209,35 @@ func main() {
180209
}
181210
}
182211

183-
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options)
212+
mgr, err := ctrl.NewManager(restConfig, options)
184213
if err != nil {
185214
setupLog.Error(err, "unable to start manager")
186215
os.Exit(1)
187216
}
188217

218+
watcher := &tlspkg.SecurityProfileWatcher{
219+
Client: mgr.GetClient(),
220+
InitialTLSProfileSpec: profile,
221+
OnProfileChange: func(_ context.Context, oldProfile, newProfile configv1.TLSProfileSpec) {
222+
if reflect.DeepEqual(oldProfile, newProfile) {
223+
return
224+
}
225+
setupLog.Info("cluster TLS profile changed, restarting operator",
226+
"oldProfileMinVersion", oldProfile.MinTLSVersion,
227+
"newProfileMinVersion", newProfile.MinTLSVersion)
228+
229+
cancel()
230+
},
231+
}
232+
233+
if err := watcher.SetupWithManager(mgr); err != nil {
234+
setupLog.Error(err, "unable to setup TLS security profile watcher")
235+
os.Exit(1)
236+
}
237+
189238
var client crclient.Client
190239
if strings.ToLower(os.Getenv("MEMORY_OPTIMIZATION_ENABLED")) != "false" {
191-
liveClient, err := crclient.New(ctrl.GetConfigOrDie(), crclient.Options{Scheme: mgr.GetScheme()})
240+
liveClient, err := crclient.New(restConfig, crclient.Options{Scheme: mgr.GetScheme()})
192241
if err != nil {
193242
setupLog.Error(err, "unable to create live client")
194243
os.Exit(1)
@@ -266,6 +315,10 @@ func main() {
266315
K8sClient: k8sClient,
267316
LocalUsers: argocdprovisioner.NewLocalUsersInfo(),
268317
FipsConfigChecker: argoutil.NewLinuxFipsConfigChecker(),
318+
CentralTlsConfigProfile: argocdprovisioner.TlsConfigProfile{
319+
MinVersion: profile.MinTLSVersion,
320+
Ciphers: profile.Ciphers,
321+
},
269322
}).SetupWithManager(mgr); err != nil {
270323
setupLog.Error(err, "unable to create controller", "controller", "Argo CD")
271324
os.Exit(1)
@@ -314,7 +367,7 @@ func main() {
314367
}
315368

316369
setupLog.Info("starting manager")
317-
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
370+
if err := mgr.Start(ctx); err != nil {
318371
setupLog.Error(err, "problem running manager")
319372
os.Exit(1)
320373
}

0 commit comments

Comments
 (0)