Skip to content

Commit

Permalink
Internal-manager-tls should contain only K8S services
Browse files Browse the repository at this point in the history
In order for Voltron (or the reverse proxy inside Voltron) to perform SNI, we must provide two sets of certificates that do not have the same SANs domains. Manager-tls will be used for external communication (requests originating from the browser) and internal-manager-tls will be used for inter-cluster communications.
  • Loading branch information
asincu committed Aug 17, 2023
1 parent 49e6426 commit 477131b
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pkg/controller/manager/manager_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,17 +321,17 @@ func (r *ReconcileManager) Reconcile(ctx context.Context, request reconcile.Requ
}

// Get or create a certificate for clients of the manager pod es-proxy container.
dnsNames := append(dns.GetServiceDNSNames(render.ManagerServiceName, render.ManagerNamespace, r.clusterDomain), render.ManagerServiceIP)
tlsSecret, err := certificateManager.GetOrCreateKeyPair(
r.client,
render.ManagerTLSSecretName,
common.OperatorNamespace(),
dnsNames)
[]string{"localhost"})
if err != nil {
r.status.SetDegraded(operatorv1.ResourceReadError, "Error getting or creating manager TLS certificate", err, reqLogger)
return reconcile.Result{}, err
}

dnsNames := dns.GetServiceDNSNames(render.ManagerServiceName, render.ManagerNamespace, r.clusterDomain)
internalTrafficSecret, err := certificateManager.GetOrCreateKeyPair(
r.client,
render.ManagerInternalTLSSecretName,
Expand Down
5 changes: 2 additions & 3 deletions pkg/controller/manager/manager_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ var _ = Describe("Manager controller tests", func() {
// Verify that the operator managed cert secrets exist. These cert
// secrets should have the manager service DNS names plus localhost only.
Expect(c.Get(ctx, types.NamespacedName{Name: render.ManagerTLSSecretName, Namespace: common.OperatorNamespace()}, secret)).ShouldNot(HaveOccurred())
test.VerifyCert(secret, expectedDNSNames...)
test.VerifyCert(secret, []string{"localhost"}...)

Expect(c.Get(ctx, types.NamespacedName{Name: render.ManagerTLSSecretName, Namespace: render.ManagerNamespace}, secret)).ShouldNot(HaveOccurred())
test.VerifyCert(secret, expectedDNSNames...)
test.VerifyCert(secret, []string{"localhost"}...)

// Check that the internal secret was copied over to the manager namespace
internalSecret := &corev1.Secret{}
Expand Down Expand Up @@ -347,7 +347,6 @@ var _ = Describe("Manager controller tests", func() {
Expect(err).ShouldNot(HaveOccurred())

dnsNames := dns.GetServiceDNSNames(render.ManagerServiceName, render.ManagerNamespace, clusterDomain)
dnsNames = append(dnsNames, "localhost")
Expect(test.GetResource(c, internalTLS)).To(BeNil())
test.VerifyCert(internalTLS, dnsNames...)
})
Expand Down
7 changes: 6 additions & 1 deletion pkg/render/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ const (
ManagerServiceName = "tigera-manager"
ManagerDeploymentName = "tigera-manager"
ManagerNamespace = "tigera-manager"
ManagerServiceIP = "localhost"
ManagerServiceAccount = "tigera-manager"
ManagerClusterRole = "tigera-manager-role"
ManagerClusterRoleBinding = "tigera-manager-binding"
Expand Down Expand Up @@ -538,6 +537,7 @@ func (c *managerComponent) managerEsProxyContainer() corev1.Container {
{Name: "FIPS_MODE_ENABLED", Value: operatorv1.IsFIPSModeEnabledString(c.cfg.Installation.FIPSMode)},
{Name: "LINSEED_CLIENT_CERT", Value: certPath},
{Name: "LINSEED_CLIENT_KEY", Value: keyPath},
{Name: "VOLTRON_URL", Value: "https://tigera-manager.tigera-manager.svc:9443"},
}

volumeMounts := append(
Expand Down Expand Up @@ -829,6 +829,11 @@ func (c *managerComponent) managerPodSecurityPolicy() *policyv1beta1.PodSecurity
// Allow users to access Calico Enterprise Manager.
func (c *managerComponent) managerAllowTigeraNetworkPolicy() *v3.NetworkPolicy {
egressRules := []v3.Rule{
{
Action: v3.Allow,
Protocol: &networkpolicy.TCPProtocol,
Destination: ManagerEntityRule,
},
{
Action: v3.Allow,
Protocol: &networkpolicy.TCPProtocol,
Expand Down
13 changes: 13 additions & 0 deletions pkg/render/testutils/expected_policies/manager.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@
}
],
"egress": [
{
"action": "Allow",
"protocol": "TCP",
"source": {
},
"destination": {
"selector": "k8s-app == 'tigera-manager'",
"namespaceSelector": "projectcalico.org/name == 'tigera-manager'",
"ports": [
9443
]
}
},
{
"action": "Allow",
"protocol": "TCP",
Expand Down
13 changes: 13 additions & 0 deletions pkg/render/testutils/expected_policies/manager_ocp.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@
}
],
"egress": [
{
"action": "Allow",
"protocol": "TCP",
"source": {
},
"destination": {
"selector": "k8s-app == 'tigera-manager'",
"namespaceSelector": "projectcalico.org/name == 'tigera-manager'",
"ports": [
9443
]
}
},
{
"action": "Allow",
"protocol": "TCP",
Expand Down

0 comments on commit 477131b

Please sign in to comment.