Skip to content

Instantly share code, notes, and snippets.

@relyt0925
Created June 6, 2022 03:45
Show Gist options
  • Save relyt0925/51be26d4bd4c122ca89753c419f96f73 to your computer and use it in GitHub Desktop.
Save relyt0925/51be26d4bd4c122ca89753c419f96f73 to your computer and use it in GitHub Desktop.
apiVersion: v1
kind: List
metadata:
name: custom-dns
items:
- apiVersion: v1
kind: Namespace
metadata:
name: custom-dns
- apiVersion: v1
kind: ServiceAccount
metadata:
name: coredns
namespace: custom-dns
- apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: system:custom-dns:coredns
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: openshift-dns
subjects:
- kind: ServiceAccount
name: coredns
namespace: custom-dns
- apiVersion: v1
kind: Service
metadata:
name: coredns
namespace: custom-dns
spec:
ports:
- name: dns
port: 53
protocol: UDP
targetPort: dns
- name: dns-tcp
port: 53
protocol: TCP
targetPort: dns-tcp
- name: metrics
port: 9153
protocol: TCP
targetPort: metrics
selector:
app: coredns
sessionAffinity: None
type: ClusterIP
- apiVersion: v1
kind: ConfigMap
metadata:
name: coredns
namespace: custom-dns
data:
Corefile: |
# Add your CoreDNS customizations as import files.
# Refer to https://cloud.ibm.com/docs/containers?topic=containers-cluster_dns for details.
.:5353 {
errors
health {
lameduck 20s
}
rewrite name exact my-on-prem-application-17146.com my-on-prem-application-17146.custom-dns.svc.cluster.local
ready
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
fallthrough in-addr.arpa ip6.arpa
ttl 120
}
prometheus :9153
forward . /etc/resolv.conf {
policy sequential
}
cache 900 {
denial 9984 30
}
reload
}
- apiVersion: apps/v1
kind: Deployment
metadata:
name: coredns
namespace: custom-dns
spec:
replicas: 1
selector:
matchLabels:
app: coredns
template:
metadata:
labels:
app: coredns
spec:
serviceAccount: coredns
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values: [ "coredns" ]
topologyKey: "kubernetes.io/hostname"
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values: [ "coredns" ]
topologyKey: topology.kubernetes.io/zone
containers:
- args:
- -conf
- /etc/coredns/Corefile
command:
- coredns
image: quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:f834b7db3bda6ee97c94869393c7a0dd24fec2bb3aba0f5c684bfaa1d7c28de3
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 5
httpGet:
path: /health
port: 8080
scheme: HTTP
initialDelaySeconds: 60
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
name: dns
ports:
- containerPort: 5353
name: dns
protocol: UDP
- containerPort: 5353
name: dns-tcp
protocol: TCP
readinessProbe:
failureThreshold: 3
httpGet:
path: /ready
port: 8181
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 3
successThreshold: 1
timeoutSeconds: 3
resources:
requests:
cpu: 50m
memory: 70Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: FallbackToLogsOnError
volumeMounts:
- mountPath: /etc/coredns
name: config-volume
readOnly: true
volumes:
- name: config-volume
configMap:
defaultMode: 420
name: coredns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment