Skip to content
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
7 changes: 1 addition & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,9 @@ licensecheck:
exit 1; \
fi

#? oas-lint: Execute OpenAPI Specification (OAS) linting https://quobix.com/vacuum/
.PHONY: go-lint
oas-lint:
go tool -modfile=go.tool.mod vacuum lint -d --fail-severity warn api/*.yaml

#? lint: Run all the linters
.PHONY: lint
lint: licensecheck go-lint oas-lint
lint: licensecheck go-lint

#? crd: Generates CRD using controller-gen and copy it into chart
.PHONY: crd
Expand Down
56 changes: 56 additions & 0 deletions docs/snippets/tutorials/coredns/coredns-groups.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
apiVersion: v1
kind: Service
metadata:
name: a
annotations:
external-dns.alpha.kubernetes.io/hostname: a.domain.local
external-dns.alpha.kubernetes.io/coredns-group: "g1"
spec:
type: LoadBalancer
status:
loadBalancer:
ingress:
- ip: 127.0.0.1
---
apiVersion: v1
kind: Service
metadata:
name: b
annotations:
external-dns.alpha.kubernetes.io/hostname: b.domain.local
external-dns.alpha.kubernetes.io/coredns-group: "g1"
spec:
type: LoadBalancer
status:
loadBalancer:
ingress:
- ip: 127.0.0.2
---
apiVersion: v1
kind: Service
metadata:
name: c
annotations:
external-dns.alpha.kubernetes.io/hostname: c.subdom.domain.local
external-dns.alpha.kubernetes.io/coredns-group: "g2"
spec:
type: LoadBalancer
status:
loadBalancer:
ingress:
- ip: 127.0.0.3
---
apiVersion: v1
kind: Service
metadata:
name: d
annotations:
external-dns.alpha.kubernetes.io/hostname: d.subdom.domain.local
external-dns.alpha.kubernetes.io/coredns-group: "g2"
spec:
type: LoadBalancer
status:
loadBalancer:
ingress:
- ip: 127.0.0.4
93 changes: 93 additions & 0 deletions docs/snippets/tutorials/coredns/etcd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# kubectl apply -f docs/snippets/tutorials/coredns/etcd.yaml
# kubectl delete -f docs/snippets/tutorials/coredns/etcd.yaml
---
apiVersion: v1
kind: Service
metadata:
name: etcd
namespace: default
spec:
type: ClusterIP
clusterIP: None
ports:
- name: etcd-client
port: 2379
- name: etcd-server
port: 2380
- name: etcd-metrics
port: 8080
selector:
app: etcd
---
apiVersion: v1
kind: Service
metadata:
name: etcd-nodeport-external
namespace: default
spec:
type: NodePort
ports:
- port: 2379
targetPort: 2379
nodePort: 32379 # must match kind config port mapping
selector:
app: etcd
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: etcd
namespace: default
spec:
serviceName: etcd
replicas: 1
selector:
matchLabels:
app: etcd
template:
metadata:
labels:
app: etcd
annotations:
serviceName: etcd
spec:
containers:
- name: etcd
image: quay.io/coreos/etcd:v3.5.15
command:
- /usr/local/bin/etcd
- --name=$(HOSTNAME)
- --listen-peer-urls=$(URI_SCHEME)://0.0.0.0:2380
- --listen-client-urls=$(URI_SCHEME)://0.0.0.0:2379
- --advertise-client-urls=$(URI_SCHEME)://$(HOSTNAME).$(SERVICE_NAME):2379
- --data-dir=/var/lib/etcd
ports:
- containerPort: 2379
volumeMounts:
- name: data
mountPath: /var/lib/etcd
env:
- name: K8S_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: HOSTNAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: SERVICE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.annotations['serviceName']
- name: ETCDCTL_ENDPOINTS
value: $(HOSTNAME).$(SERVICE_NAME):2379
- name: URI_SCHEME
value: "http"
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 50Mi
43 changes: 43 additions & 0 deletions docs/snippets/tutorials/coredns/fixtures.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# kubectl apply -f docs/snippets/tutorials/coredns/fixtures.yaml
# kubectl delete -f docs/snippets/tutorials/coredns/fixtures.yaml
# kubectl get svc -l svc=test-svc
---
apiVersion: v1
kind: Service
metadata:
name: a-g1-record
labels:
svc: test-svc
annotations:
external-dns.alpha.kubernetes.io/hostname: a.example.org
external-dns.alpha.kubernetes.io/coredns-group: "g1"
cluster-name: "cluster1"
namespace: default
spec:
type: LoadBalancer
ports:
- port: 80
name: http
targetPort: 80
selector:
app: test-app
---
apiVersion: v1
kind: Service
metadata:
name: aa-g1-record
labels:
svc: test-svc
annotations:
external-dns.alpha.kubernetes.io/hostname: aa.example.org
external-dns.alpha.kubernetes.io/coredns-group: "g1"
cluster-name: "cluster1"
namespace: default
spec:
type: LoadBalancer
ports:
- port: 80
name: http
targetPort: 80
selector:
app: test-app
38 changes: 38 additions & 0 deletions docs/snippets/tutorials/coredns/kind.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ref: https://kind.sigs.k8s.io/docs/user/quick-start/
# https://kind.sigs.k8s.io/docs/user/configuration/#extra-port-mappings

# kind create cluster --config=docs/snippets/tutorials/coredns/kind.yaml
# kind delete cluster --name coredns-etcd
# kubectl cluster-info --context kind-coredns-etcd
# kubectl get nodes -o wide
---
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: coredns-etcd
networking:
apiServerAddress: 127.0.0.1
apiServerPort: 6443
nodes:
- role: control-plane
image: kindest/node:v1.33.0
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 8080
listenAddress: "0.0.0.0"
protocol: TCP
- containerPort: 43
hostPort: 4443
listenAddress: "0.0.0.0"
protocol: TCP
- containerPort: 32379 # inside kind node
hostPort: 32379 # exposed on host
listenAddress: "0.0.0.0"
protocol: TCP
- role: worker
image: kindest/node:v1.33.0
53 changes: 53 additions & 0 deletions docs/snippets/tutorials/coredns/values-coredns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# kubectl logs deploy/coredns -n default -c coredns
# ref: https://github.com/coredns/helm/blob/master/charts/coredns/values.yaml
isClusterService: false

service:
name: coredns
port: 53
annotations: {}
clusterIP: ""

# Main customization
servers:
- zones:
- zone: .
port: 53
plugins:
- name: errors
- name: debug # <── enables debug mode
- name: health
configBlock: |-
lameduck 5s
- name: ready
# to query kubernetes API for data
- name: kubernetes
parameters: cluster.local 10.0.0.0/24
configBlock: |-
pods insecure
fallthrough in-addr.arpa ip6.arpa
ttl 30
- name: etcd
parameters: "example.org"
configBlock: |
stubzones
path /skydns
endpoint http://etcd.default.svc.cluster.local:2379
fallthrough
- name: log # <── log each DNS query
- name: forward
parameters: ". /etc/resolv.conf"
- name: cache
parameters: 30
- name: reload
- name: loop
- name: loadbalance

replicaCount: 1

# required to debug DNS resolution from within CoreDNS pods
# kubectl logs deploy/coredns -n default -c resolv-check --tail=50
initContainers:
- name: resolv-check
image: busybox:1.37
command: ["sh", "-c", "echo '--- /etc/resolv.conf ---'; cat /etc/resolv.conf; echo '---------------------------'; nslookup kubernetes.default.svc.cluster.local || true; sleep 5"]
39 changes: 39 additions & 0 deletions docs/snippets/tutorials/coredns/values-extdns-coredns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

# ref: https://github.com/kubernetes-sigs/external-dns/blob/master/charts/external-dns/values.yaml
provider:
name: coredns

env:
- name: ETCD_URLS
value: "http://etcd.default.svc.cluster.local:2379"


txtOwnerId: cluster1
# Filter resources queried for endpoints by annotation, using label selector semantics
annotationFilter: cluster-name=cluster1

domainFilters:
- example.org

# Sources define what ExternalDNS will use to discover endpoints
sources:
- service

# Policy options
policy: sync

logLevel: debug
interval: 1m

# RBAC configuration
rbac:
create: true

# Optional: tune resource requests
resources:
requests:
cpu: 100m
memory: 64Mi
limits:
cpu: 200m
memory: 128Mi
Loading