-
Notifications
You must be signed in to change notification settings - Fork 1.5k
CORS-4137: add CoreDNS upstream resolver config for dual-stack clusters #10362
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
Closed
Closed
Changes from all commits
Commits
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 hidden or 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,115 @@ | ||
| package manifests | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "path" | ||
|
|
||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "sigs.k8s.io/yaml" | ||
|
|
||
| operatorv1 "github.com/openshift/api/operator/v1" | ||
| "github.com/openshift/installer/pkg/asset" | ||
| "github.com/openshift/installer/pkg/asset/installconfig" | ||
| awstypes "github.com/openshift/installer/pkg/types/aws" | ||
| "github.com/openshift/installer/pkg/types/dns" | ||
| ) | ||
|
|
||
| var ( | ||
| coreDNSCfgFilename = path.Join(manifestDir, "coredns-02-config.yml") | ||
| ) | ||
|
|
||
| // CoreDNS generates the files to configure CoreDNS component, which provides a name resolution service | ||
| // for pods and services in the cluster. | ||
| type CoreDNS struct { | ||
| FileList []*asset.File | ||
| } | ||
|
|
||
| var _ asset.WritableAsset = (*CoreDNS)(nil) | ||
|
|
||
| // Name returns a human friendly name for the asset. | ||
| func (*CoreDNS) Name() string { | ||
| return "CoreDNS Config" | ||
| } | ||
|
|
||
| // Dependencies returns all of the dependencies directly needed to generate | ||
| // the asset. | ||
| func (*CoreDNS) Dependencies() []asset.Asset { | ||
| return []asset.Asset{ | ||
| &installconfig.InstallConfig{}, | ||
| } | ||
| } | ||
|
|
||
| // Generate generates the CoreDNS config and its CRD. | ||
| func (d *CoreDNS) Generate(ctx context.Context, dependencies asset.Parents) error { | ||
| installConfig := &installconfig.InstallConfig{} | ||
| dependencies.Get(installConfig) | ||
|
|
||
| var controllerConfig *operatorv1.DNS | ||
|
|
||
| switch installConfig.Config.Platform.Name() { | ||
| case awstypes.Name: | ||
| // We don't configure coreDNS here when UserProvisionedDNS is enabled | ||
| if installConfig.Config.AWS.UserProvisionedDNS == dns.UserProvisionedDNSEnabled { | ||
| return nil | ||
| } | ||
|
|
||
| if installConfig.Config.AWS.IPFamily.DualStackEnabled() { | ||
| // By default, in dualstack subnets, the resolver config file on instances only define the IPv4 DNS resolver. | ||
| // For dualstack, we need to also allow the IPv6 DNS resolver "fd00:ec2::253" | ||
| // See: https://docs.aws.amazon.com/whitepapers/latest/ipv6-on-aws/supporting-amazon-vpc-services.html#route-53-dns-resolver | ||
| controllerConfig = &operatorv1.DNS{ | ||
| TypeMeta: metav1.TypeMeta{ | ||
| APIVersion: operatorv1.SchemeGroupVersion.String(), | ||
| Kind: "DNS", | ||
| }, | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: "default", | ||
| // not namespaced | ||
| }, | ||
| Spec: operatorv1.DNSSpec{ | ||
| UpstreamResolvers: operatorv1.UpstreamResolvers{ | ||
| Policy: operatorv1.SequentialForwardingPolicy, | ||
| Upstreams: []operatorv1.Upstream{ | ||
| { | ||
| Type: operatorv1.SystemResolveConfType, | ||
| }, | ||
| { | ||
|
|
||
| Type: operatorv1.NetworkResolverType, | ||
| Address: "fd00:ec2::253", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
| } | ||
| default: | ||
| } | ||
|
|
||
| if controllerConfig != nil { | ||
| configData, err := yaml.Marshal(controllerConfig) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to create %s manifests from InstallConfig: %w", d.Name(), err) | ||
| } | ||
|
|
||
| d.FileList = []*asset.File{ | ||
| { | ||
| Filename: coreDNSCfgFilename, | ||
| Data: configData, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| // Files returns the files generated by the asset. | ||
| func (d *CoreDNS) Files() []*asset.File { | ||
| return d.FileList | ||
| } | ||
|
|
||
| // Load loads the already-rendered files back from disk. | ||
| func (d *CoreDNS) Load(f asset.FileFetcher) (bool, error) { | ||
| return false, nil | ||
| } | ||
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.