-
Notifications
You must be signed in to change notification settings - Fork 689
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/provisioner: support more than one instance per namespace #4426
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
50b03f1
support multiple Gateways/contour instances per ns
skriss 3908fdb
set envoy-service-name correctly
skriss 8a7a8ab
clean up resource name generation
skriss 1ec9d55
multiple gateways per namespace E2E
skriss 9b4c565
move name generation into model, use everywhere
skriss b06fc00
changelog
skriss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Gateway provisioner: add support for more than one Gateway/Contour instance per namespace | ||
|
||
The Gateway provisioner now supports having more than one Gateway/Contour instance per namespace. | ||
All resource names now include a `-<gateway-name>` suffix to avoid conflicts (cluster-scoped resources also include the namespace as part of the resource name). | ||
Contour instances are always provisioned in the namespace of the Gateway custom resource itself. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
// Copyright Project Contour Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package model | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
// ConfigMapName returns the name of the Contour ConfigMap resource. | ||
func (c *Contour) ConfigMapName() string { | ||
return "contour-" + c.Name | ||
} | ||
|
||
// ContourServiceName returns the name of the Contour Service resource. | ||
func (c *Contour) ContourServiceName() string { | ||
return "contour-" + c.Name | ||
} | ||
|
||
// EnvoyServiceName returns the name of the Envoy Service resource. | ||
func (c *Contour) EnvoyServiceName() string { | ||
return "envoy-" + c.Name | ||
} | ||
|
||
// ContourDeploymentName returns the name of the Contour Deployment resource. | ||
func (c *Contour) ContourDeploymentName() string { | ||
return "contour-" + c.Name | ||
} | ||
|
||
// EnvoyDaemonSetName returns the name of the Envoy DaemonSet resource. | ||
func (c *Contour) EnvoyDaemonSetName() string { | ||
return "envoy-" + c.Name | ||
} | ||
|
||
// LeaderElectionLeaseName returns the name of the Contour leader election Lease resource. | ||
func (c *Contour) LeaderElectionLeaseName() string { | ||
return "leader-elect-" + c.Name | ||
} | ||
|
||
// ContourCertsSecretName returns the name of the Contour xDS TLS certs Secret resource. | ||
func (c *Contour) ContourCertsSecretName() string { | ||
return c.Name + "-contourcert" | ||
} | ||
|
||
// EnvoyCertsSecretName returns the name of the Envoy xDS TLS certs Secret resource. | ||
func (c *Contour) EnvoyCertsSecretName() string { | ||
return c.Name + "-envoycert" | ||
} | ||
|
||
// CertgenJobName returns the name of the certgen Job resource. | ||
func (c *Contour) CertgenJobName(contourImage string) string { | ||
return fmt.Sprintf("contour-certgen-%s-%s", tagFromImage(contourImage), c.Name) | ||
} | ||
|
||
// tagFromImage returns the tag from the provided image or an | ||
// empty string if the image does not contain a tag. | ||
func tagFromImage(image string) string { | ||
if strings.Contains(image, ":") { | ||
parsed := strings.Split(image, ":") | ||
return parsed[1] | ||
} | ||
return "" | ||
} | ||
|
||
// ContourRBACNames returns the names of the RBAC resources for | ||
// the Contour deployment. | ||
func (c *Contour) ContourRBACNames() RBACNames { | ||
return RBACNames{ | ||
ServiceAccount: fmt.Sprintf("contour-%s", c.Name), | ||
ClusterRole: fmt.Sprintf("contour-%s-%s", c.Namespace, c.Name), | ||
ClusterRoleBinding: fmt.Sprintf("contour-%s-%s", c.Namespace, c.Name), | ||
Role: fmt.Sprintf("contour-%s", c.Name), | ||
|
||
// this one has a different prefix to differentiate from the certgen role binding (see below). | ||
RoleBinding: fmt.Sprintf("contour-rolebinding-%s", c.Name), | ||
} | ||
} | ||
|
||
// EnvoyRBACNames returns the names of the RBAC resources for | ||
// the Envoy daemonset. | ||
func (c *Contour) EnvoyRBACNames() RBACNames { | ||
return RBACNames{ | ||
ServiceAccount: "envoy-" + c.Name, | ||
} | ||
} | ||
|
||
// CertgenRBACNames returns the names of the RBAC resources for | ||
// the Certgen job. | ||
func (c *Contour) CertgenRBACNames() RBACNames { | ||
return RBACNames{ | ||
ServiceAccount: "contour-certgen-" + c.Name, | ||
Role: "contour-certgen-" + c.Name, | ||
|
||
// this one is name contour-<gateway-name> despite being for certgen for legacy reasons. | ||
RoleBinding: "contour-" + c.Name, | ||
} | ||
} | ||
|
||
// RBACNames holds a set of names of related RBAC resources. | ||
type RBACNames struct { | ||
ServiceAccount string | ||
ClusterRole string | ||
ClusterRoleBinding string | ||
Role string | ||
RoleBinding string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a subsequent PR that flips these cert secrets' names around to use the Gateway name as a suffix rather than a prefix, for consistency. Will be done as part of directly generating the certs rather than using the Job.