Skip to content
Closed
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
614 changes: 614 additions & 0 deletions docs/contributing/unstructured-source.md

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions docs/contributing/unstructured-source/clusterworkload-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---

apiVersion: example.com/v1alpha1
kind: ClusterWorkload
metadata:
name: my-workload-1
annotations:
example: my-workload-1
description: |
This example results in the creation of a single endpoint with
one, A-record targets, an IP4 address. The endpoint's DNS name
and TTL are derived from the spec and annotations below, and
since no record type is specified, the default type, A-record,
is used.

This example highlights that the unstructured source may be used
with cluster-scoped resources as well.
external-dns.alpha.kubernetes.io/ttl: 10m
spec:
hostname: my-workload-1.example.com
# kubectl is disallowed from editing the status sub-resource. it is included
# here for completeness, but the example actually used curl to set the status
status:
addr: 1.2.3.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: clusterworkloads.example.com
spec:
group: example.com
names:
kind: ClusterWorkload
listKind: ClusterWorkloadList
plural: clusterworkloads
singular: clusterworkload
scope: Cluster
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: WorkloadSpec defines the desired state of Workload
properties:
hostname:
description: The hostname used to identify the workload.
type: string
additionalHostnames:
description: Additional hostnames used to identify the workload.
items:
type: string
type: array
type: object
status:
description: WorkloadStatus defines the observed state of Workload
properties:
addr:
description: The address at which the workload can be reached.
type: string
additionalAddrs:
description: Additional addresses at which the workload can be reached.
items:
type: string
type: array
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
37 changes: 37 additions & 0 deletions docs/contributing/unstructured-source/configmap-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---

apiVersion: v1
kind: ConfigMap
metadata:
name: my-workload-1
annotations:
example: my-workload-1
description: |
This example results in the creation of a single endpoint with
one three, A-record targets -- one IP4 addr and two IP6 addrs.
The endpoint's DNS name and TTL are derived from the annotations
below, and since no record type is specified, the default type,
A-record, is used.
external-dns.alpha.kubernetes.io/hostname: my-workload-1.example.com
external-dns.alpha.kubernetes.io/ttl: 10m
data:
ip4-addrs: 1.2.3.4
ip6-addrs: "2001:db8:0:1:1:1:1:1,2001:db8:0:1:1:1:1:2"

---

apiVersion: v1
kind: ConfigMap
metadata:
name: my-workload-2
annotations:
example: my-workload-2
description: |
This example results in the creation of two endpoints with
one, A-record targets, an IP4 address. An endpoint is created
for each of the DNS names specified in the annotation below.
Since no TTL or record type are specified, the default values
for each are used, a TTL of 0 and an A-record.
external-dns.alpha.kubernetes.io/hostname: my-workload-1.example.com, my-workload-2.example.com
data:
ip4-addrs: 1.2.3.4
32 changes: 32 additions & 0 deletions docs/contributing/unstructured-source/deployment-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---

apiVersion: apps/v1
kind: Deployment
metadata:
name: my-workload-1
labels:
app: my-workload-1
annotations:
example: my-workload-1
description: |
This example results in the creation of two endpoints with
one, CNAME-record targets, a hostname. An endpoint is created
for each of the DNS names specified in the annotation below.
Since no TTL is specified, the default value, a TTL of 0, is
used.
external-dns.alpha.kubernetes.io/hostname: my-workload-1a.example.com my-workload-1b.example.com
external-dns.alpha.kubernetes.io/record-type: CNAME
external-dns.alpha.kubernetes.io/target: my-workload-1.example.com
spec:
replicas: 0
selector:
matchLabels:
app: my-workload-1
template:
metadata:
labels:
app: my-workload-1
spec:
containers:
- name: nginx
image: nginx:1.14.2
69 changes: 69 additions & 0 deletions docs/contributing/unstructured-source/workload-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---

apiVersion: example.com/v1alpha1
kind: Workload
metadata:
name: my-workload-1
annotations:
example: my-workload-1
description: |
This example results in the creation of a single endpoint with
one, A-record target, an IP4 address. The endpoint's DNS name
and TTL are derived from the annotations below, and since no
record type is specified, the default type, A-record, is used.
external-dns.alpha.kubernetes.io/hostname: my-workload-1.example.com
external-dns.alpha.kubernetes.io/ttl: 10m
spec: {}
# kubectl is disallowed from editing the status sub-resource. it is included
# here for completeness, but the example actually used curl to set the status
status:
addr: 1.2.3.4

---

apiVersion: example.com/v1alpha1
kind: Workload
metadata:
name: my-workload-2
annotations:
example: my-workload-2
description: |
This example results in the creation of three endpoints with
one, A-record target, an IP4 address. An endpoint is created
for each of the DNS names specified in the spec below.
Since no TTL or record type are specified, the default values
for each are used, a TTL of 0 and an A-record.
spec:
hostname: my-workload-2.example.com
additionalHostnames:
- my-workload-2a.example.com
- my-workload-2b.example.com
# kubectl is disallowed from editing the status sub-resource. it is included
# here for completeness, but the example actually used curl to set the status
status:
addr: 1.2.3.4

---

apiVersion: example.com/v1alpha1
kind: Workload
metadata:
name: my-workload-3
annotations:
example: my-workload-3
description: |
This example results in the creation of a single endpoint with
one four, A-record targets -- two IP4 addrs and two IP6 addrs.
The endpoint's DNS is derived from the spec below. Since no
TTL or record type are specified, the default values for each
are used, a TTL of 0 and an A-record.
spec:
hostname: my-workload-3.example.com
# kubectl is disallowed from editing the status sub-resource. it is included
# here for completeness, but the example actually used curl to set the status
status:
addr: 1.2.3.4
additionalAddrs:
- 5.6.7.8
- 2001:db8:0:1:1:1:1:1
- 2001:db8:0:1:1:1:1:2
61 changes: 61 additions & 0 deletions docs/contributing/unstructured-source/workload-manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: workloads.example.com
spec:
group: example.com
names:
kind: Workload
listKind: WorkloadList
plural: workloads
singular: workload
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: WorkloadSpec defines the desired state of Workload
properties:
hostname:
description: The hostname used to identify the workload.
type: string
additionalHostnames:
description: Additional hostnames used to identify the workload.
items:
type: string
type: array
type: object
status:
description: WorkloadStatus defines the observed state of Workload
properties:
addr:
description: The address at which the workload can be reached.
type: string
additionalAddrs:
description: Additional addresses at which the workload can be reached.
items:
type: string
type: array
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
62 changes: 33 additions & 29 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,35 +110,39 @@ func main() {

// Create a source.Config from the flags passed by the user.
sourceCfg := &source.Config{
Namespace: cfg.Namespace,
AnnotationFilter: cfg.AnnotationFilter,
LabelFilter: labelSelector,
FQDNTemplate: cfg.FQDNTemplate,
CombineFQDNAndAnnotation: cfg.CombineFQDNAndAnnotation,
IgnoreHostnameAnnotation: cfg.IgnoreHostnameAnnotation,
IgnoreIngressTLSSpec: cfg.IgnoreIngressTLSSpec,
IgnoreIngressRulesSpec: cfg.IgnoreIngressRulesSpec,
GatewayNamespace: cfg.GatewayNamespace,
GatewayLabelFilter: cfg.GatewayLabelFilter,
Compatibility: cfg.Compatibility,
PublishInternal: cfg.PublishInternal,
PublishHostIP: cfg.PublishHostIP,
AlwaysPublishNotReadyAddresses: cfg.AlwaysPublishNotReadyAddresses,
ConnectorServer: cfg.ConnectorSourceServer,
CRDSourceAPIVersion: cfg.CRDSourceAPIVersion,
CRDSourceKind: cfg.CRDSourceKind,
KubeConfig: cfg.KubeConfig,
APIServerURL: cfg.APIServerURL,
ServiceTypeFilter: cfg.ServiceTypeFilter,
CFAPIEndpoint: cfg.CFAPIEndpoint,
CFUsername: cfg.CFUsername,
CFPassword: cfg.CFPassword,
ContourLoadBalancerService: cfg.ContourLoadBalancerService,
GlooNamespace: cfg.GlooNamespace,
SkipperRouteGroupVersion: cfg.SkipperRouteGroupVersion,
RequestTimeout: cfg.RequestTimeout,
DefaultTargets: cfg.DefaultTargets,
OCPRouterName: cfg.OCPRouterName,
Namespace: cfg.Namespace,
AnnotationFilter: cfg.AnnotationFilter,
LabelFilter: labelSelector,
FQDNTemplate: cfg.FQDNTemplate,
CombineFQDNAndAnnotation: cfg.CombineFQDNAndAnnotation,
IgnoreHostnameAnnotation: cfg.IgnoreHostnameAnnotation,
IgnoreIngressTLSSpec: cfg.IgnoreIngressTLSSpec,
IgnoreIngressRulesSpec: cfg.IgnoreIngressRulesSpec,
GatewayNamespace: cfg.GatewayNamespace,
GatewayLabelFilter: cfg.GatewayLabelFilter,
Compatibility: cfg.Compatibility,
PublishInternal: cfg.PublishInternal,
PublishHostIP: cfg.PublishHostIP,
AlwaysPublishNotReadyAddresses: cfg.AlwaysPublishNotReadyAddresses,
ConnectorServer: cfg.ConnectorSourceServer,
CRDSourceAPIVersion: cfg.CRDSourceAPIVersion,
CRDSourceKind: cfg.CRDSourceKind,
KubeConfig: cfg.KubeConfig,
APIServerURL: cfg.APIServerURL,
ServiceTypeFilter: cfg.ServiceTypeFilter,
CFAPIEndpoint: cfg.CFAPIEndpoint,
CFUsername: cfg.CFUsername,
CFPassword: cfg.CFPassword,
ContourLoadBalancerService: cfg.ContourLoadBalancerService,
GlooNamespace: cfg.GlooNamespace,
SkipperRouteGroupVersion: cfg.SkipperRouteGroupVersion,
RequestTimeout: cfg.RequestTimeout,
DefaultTargets: cfg.DefaultTargets,
OCPRouterName: cfg.OCPRouterName,
UnstructuredSourceAPIVersion: cfg.UnstructuredSourceAPIVersion,
UnstructuredSourceKind: cfg.UnstructuredSourceKind,
UnstructuredSourceTargetJsonPath: cfg.UnstructuredSourceTargetJsonPath,
UnstructuredSourceHostnameJsonPath: cfg.UnstructuredSourceHostnameJsonPath,
}

// Lookup all the selected sources by names and pass them the desired configuration.
Expand Down
Loading