Skip to content

Commit

Permalink
Merge pull request #4367 from sadasu/custom-dns
Browse files Browse the repository at this point in the history
OCPBUGS-29067: GCP Custom-DNS: Update services that run on control plane nodes
  • Loading branch information
openshift-merge-bot[bot] authored Jan 23, 2025
2 parents 6fef6ad + 057219e commit 11b9ad0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
25 changes: 25 additions & 0 deletions templates/common/gcp/files/usr-local-bin-update-dns-server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
mode: 0755
path: "/usr/local/bin/update-dns-server"
contents:
inline: |
#!/bin/bash
# For GCP, updating the NetworkManager configuration file to
# include the IP address of the local node as the default DNS
# resolver when UserProvisionedDNS is enabled.
# A CoreDNS static pod running on the node is responsible for
# resolving the api, api-int and *.apps URLs.
mkdir -p /etc/NetworkManager/conf.d
cat <<EOF | tee /etc/NetworkManager/conf.d/dns-servers.conf
# Added by OpenShift
[global-dns-domain-*]
servers=$(ip --json route get 8.8.8.8 | jq -r ".[0].prefsrc"),169.254.169.254
EOF
# network manager may already be running at this point.
# reload to update /etc/resolv.conf with this configuration
nmcli general reload conf
nmcli general reload dns-rc
echo "Done updating dns-server.conf"
19 changes: 19 additions & 0 deletions templates/common/gcp/units/gcp-update-dns.service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: gcp-update-dns.service
enabled: {{if and (eq .Infra.Status.PlatformStatus.Type "GCP") (.Infra.Status.PlatformStatus.GCP) (.Infra.Status.PlatformStatus.GCP.CloudLoadBalancerConfig) (eq .Infra.Status.PlatformStatus.GCP.CloudLoadBalancerConfig.DNSType "ClusterHosted") }}true{{else}}false{{end}}
contents: |
[Unit]
Description=Update Default GCP Resolver
# We don't need to do this on the firstboot
After=firstboot-osupdate.target
# Wait for NetworkManager to report it's online
After=NetworkManager-wait-online.service
# Run before kubelet
Before=kubelet-dependencies.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/update-dns-server
[Install]
RequiredBy=kubelet-dependencies.target
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: openshift-gcp-routes.service
enabled: true
enabled: {{if and (eq .Infra.Status.PlatformStatus.Type "GCP") (.Infra.Status.PlatformStatus.GCP) (.Infra.Status.PlatformStatus.GCP.CloudLoadBalancerConfig) (eq .Infra.Status.PlatformStatus.GCP.CloudLoadBalancerConfig.DNSType "ClusterHosted") }}false{{else}}true{{end}}
contents: |
[Unit]
Description=Update GCP routes for forwarded IPs.
Expand Down

0 comments on commit 11b9ad0

Please sign in to comment.