Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal-manager-tls should contain only K8S services #2810

Merged
merged 1 commit into from
Aug 17, 2023
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
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