Skip to content

Commit

Permalink
add README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
penglongli committed Jan 26, 2021
1 parent f99f7ff commit c69ad3c
Show file tree
Hide file tree
Showing 13 changed files with 161 additions and 48 deletions.
89 changes: 84 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,87 @@
# binddns-operator [Developing]
BindDns Operator creates/configures/manages bind9 dns atop Kubernetes
# binddns-operator

Users can use crd DnsDomain/DnsRule to change dns rules.
You can simply manages your DNS records with binddns-operator.

<b>This repo is developing</b>
DnsDomain/DnsRule is the CRD of Kubernetes. Users can use them to change DNS records.

![show](docs/summary.gif)

## The Example

```
[root@localhost ~]# kubectl get dnsdomain
NAME ENABLED REMARK UPDATE
helloworld.com true 2021-01-21 01:44:05
test.com true 2021-01-20 21:38:09
[root@localhost ~]# kubectl get dnsrule
NAME ZONE ENABLED HOST TYPE DATA TTL MXPRIORITY
helloworld.com-b3378a6c helloworld.com true www A 1.1.1.1 10 0
test.com-8b223ed7 test.com true www A 10.10.10.10 10 0
[root@localhost ~]# nslookup www.test.com 127.0.0.1
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: www.test.com
Address: 10.10.10.10
```

## How To Deploy

We need to deploy Controller and Webhook

### Deploy Controller

```
[root@localhost binddns-operator]# cd deploy/controller/
# Deploy DnsDomain CRD
[root@localhost controller]# kubectl apply -f crd_dnsdomains.yaml
# Deploy DnsRule CRD
[root@localhost controller]# kubectl apply -f crd_dnsrules.yaml
# Deploy RBAC
[root@localhost controller]# kubectl apply -f rbac.yaml
# Deploy ConfigMap
[root@localhost controller]# kubectl apply -f configmap.yaml
# Deploy Controller Deployment
[root@localhost controller]# kubectl apply -f deployment.yaml
```

### Deploy Webhook

```
[root@localhost binddns-operator]# cd deploy/webhook/
# Generate Secret
[root@localhost webhook]# ./webhook-create-signed-cert.sh --service binddns-webhook-svc --secret binddns-webhook-certs --namespace kube-system
# Generate Deployment
[root@localhost webhook]# cat mutatingwebhook.yaml | ./webhook-patch-ca-bundle.sh > mutatingwebhook-ca-bundle.yaml
# Deploy
[root@localhost webhook]# kubectl apply -f mutatingwebhook-ca-bundle.yaml
[root@localhost webhook]# kubectl apply -f service.yaml
[root@localhost webhook]# kubectl apply -f deployment.yaml
```

## Usage

- WebUI: [http://${IP}:5388/console/domains](http://${IP}:5388/console/domains)

- CRD: There is a demo at [deploy/demo/example.yaml](deploy/demo/example.yaml)


## Future

- The better WebUI
- Dynamic rndc key
- Synchronous DnsDomain status
- ...

![show](docs/summary.gif)
4 changes: 2 additions & 2 deletions deploy/controller/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: rndc-conf
namespace: default
namespace: kube-system
data:
rndc.conf: |
# Start of rndc.conf
Expand All @@ -24,7 +24,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: bind-conf
namespace: default
namespace: kube-system
data:
named.conf: |
options {
Expand Down
52 changes: 30 additions & 22 deletions deploy/controller/crd_dnsdomains.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,28 @@ metadata:
creationTimestamp: null
name: dnsdomains.binddns.github.com
spec:
additionalPrinterColumns:
- JSONPath: .spec.enabled
name: enabled
type: boolean
- JSONPath: .spec.remark
name: remark
type: string
- JSONPath: .status.updateTime
name: update
type: string
- JSONPath: .status.phase
name: status
type: string
group: binddns.github.com
names:
kind: DnsDomain
listKind: DnsDomainList
plural: dnsdomains
singular: dnsdomain
scope: Namespaced
scope: Cluster
subresources:
status: {}
validation:
openAPIV3Schema:
properties:
Expand All @@ -32,51 +47,44 @@ spec:
description: Standard object metadata.
type: object
spec:
description: Specification of the desired behavior of the DnsInstance.
description: Specification of the desired behavior of the DnsDomain.
properties:
enabled:
description: Enabled defines whether enable the domain. Default true,
not required
description: Enabled defines whether enable the domain.
type: boolean
name:
description: Name defines the domain name.
type: string
remark:
description: Remark defines the remark for the domain, base64 format.
type: string
required:
- enabled
- remark
type: object
status:
description: Most recently observed status of the DnsInstance.
description: Most recently observed status of the DnsDomain.
properties:
condition:
createTime:
description: CreateTime defines the domain create time.
type: string
instanceStatuses:
additionalProperties:
properties:
instanceName:
name:
type: string
status:
type: string
required:
- instanceName
- status
updatedAt:
type: string
type: object
description: Codition defines the
description: InstanceStatuses defines the domain status of every instance
type: object
createTime:
description: CreateTime defines the domain create time.
phase:
type: string
updateTime:
description: UpdateTime defines the domain update time.
type: string
required:
- condition
- createTime
- updateTime
type: object
required:
- status
- metadata
- spec
type: object
version: v1
versions:
Expand Down
47 changes: 36 additions & 11 deletions deploy/controller/crd_dnsrules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,37 @@ metadata:
creationTimestamp: null
name: dnsrules.binddns.github.com
spec:
additionalPrinterColumns:
- JSONPath: .spec.zone
name: Zone
type: string
- JSONPath: .spec.enabled
name: Enabled
type: boolean
- JSONPath: .spec.host
name: Host
type: string
- JSONPath: .spec.type
name: Type
type: string
- JSONPath: .spec.data
name: Data
type: string
- JSONPath: .spec.ttl
name: Ttl
type: number
- JSONPath: .spec.mxPriority
name: MxPriority
type: number
group: binddns.github.com
names:
kind: DnsRule
listKind: DnsRuleList
plural: dnsrules
singular: dnsrule
scope: Namespaced
scope: Cluster
subresources:
status: {}
validation:
openAPIV3Schema:
properties:
Expand All @@ -32,17 +56,15 @@ spec:
description: Standard object metadata.
type: object
spec:
description: Specification of the desired behavior of the DnsInstance.
description: Specification of the desired behavior of the DnsRule.
properties:
data:
type: string
domainName:
type: string
enabled:
type: boolean
host:
type: string
maxPriority:
mxPriority:
format: int32
type: integer
ttl:
Expand All @@ -53,20 +75,23 @@ spec:
zone:
type: string
required:
- data
- enabled
- maxPriority
- host
- ttl
- type
- zone
type: object
status:
description: Most recently observed status of the DnsInstance.
description: Most recently observed status of the DnsRule.
properties:
status:
createTime:
type: string
updateTime:
type: string
required:
- status
type: object
required:
- spec
- status
type: object
version: v1
versions:
Expand Down
2 changes: 1 addition & 1 deletion deploy/controller/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Deployment
apiVersion: apps/v1
metadata:
name: binddns-controller
namespace: default
namespace: kube-system
spec:
replicas: 1
selector:
Expand Down
4 changes: 2 additions & 2 deletions deploy/controller/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: binddns-sa
namespace: default
namespace: kube-system

---
kind: ClusterRole
Expand All @@ -23,7 +23,7 @@ metadata:
subjects:
- kind: ServiceAccount
name: binddns-sa
namespace: default
namespace: kube-system
roleRef:
kind: ClusterRole
name: binddns-role
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion deploy/webhook/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: binddns-webhook
namespace: default
namespace: kube-system
labels:
app: binddns-webhook
spec:
Expand Down
2 changes: 1 addition & 1 deletion deploy/webhook/mutatingwebhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ webhooks:
clientConfig:
service:
name: binddns-webhook-svc
namespace: default
namespace: kube-system
path: "/mutate"
caBundle: ${CA_BUNDLE}
rules:
Expand Down
2 changes: 1 addition & 1 deletion deploy/webhook/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
kind: Service
metadata:
name: binddns-webhook-svc
namespace: default
namespace: kube-system
labels:
app: binddns-webhook-svc
spec:
Expand Down
Binary file modified docs/summary.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions pkg/controller/router/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func createRule(ctx *gin.Context) {
})
return
}
ctx.JSON(http.StatusOK, &Response{Code: SUCCESS})
}

func deleteRule(ctx *gin.Context) {
Expand Down
4 changes: 2 additions & 2 deletions webapp/html/rule.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ <h2>Records</h2>
"host": host,
"type": type,
"data": data,
"ttl": ttl,
"mxPriority": mxPriority,
"ttl": parseInt(ttl),
"mxPriority": parseInt(mxPriority),
}),
success: function (data) {
if (data.code === 0) {
Expand Down

0 comments on commit c69ad3c

Please sign in to comment.