-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs: Initial doc on how to create a new provider
- Loading branch information
1 parent
a6b12c6
commit b5ab1bf
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
title: 'Create a provider' | ||
date: 2024-10-20T10:38:15-04:00 | ||
draft: false | ||
--- | ||
|
||
The `DNSIntegration` CRD was created to allow anyone to create their own provider and manage DNSRecord using Phonebook. Here you will find all the information to create your own provider. | ||
|
||
## Concepts | ||
|
||
To understand how integrations work, it's best to visualize Phonebook as a disjointed Kubernetes Operator. Each integration runs a deployment that register a new operator that will listen for `DNSRecord` and only act on the ones that fits their integration profile. | ||
|
||
Phonebook's main controller has the responsibility of validating new DNSRecord as well as ensuring that records can be safely garbage collected when deleted. All the actual operations between a DNSRecord and a DNS Provider is done through the DNSIntegration's deployment. | ||
|
||
## A Provider's main function | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pier-oliviert/phonebook/pkg/providers/cloudflare" | ||
"github.com/pier-oliviert/phonebook/pkg/server" | ||
"sigs.k8s.io/controller-runtime/pkg/log" | ||
) | ||
|
||
func main() { | ||
var err error | ||
|
||
ctx := context.Background() | ||
logger := log.FromContext(ctx) | ||
|
||
logger.Info("Initializing My New Client") | ||
|
||
// Replace this with your provider's client | ||
// The client needs to implement the providers.Provider interface | ||
p, err := cloudflare.NewClient(ctx) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
srv := server.NewServer(p) | ||
if err := srv.Run(); err != nil { | ||
panic(err) | ||
} | ||
} | ||
``` | ||
|
||
The server that Phonebook provides is a fully configured operator. The call `srv.Run()` will block and will then pass off all the request to the client. |