|
| 1 | +# argocd-capi-operator |
| 2 | + |
| 3 | +Register [Cluster](https://doc.crds.dev/github.com/kubernetes-sigs/cluster-api/cluster.x-k8s.io/Cluster/v1beta1@v1.8.3) resources using [ArgoCD Cluster API](https://pkg.go.dev/github.com/argoproj/argo-cd/v2@v2.12.3/pkg/apiclient/cluster#ClusterServiceClient). |
| 4 | + |
| 5 | +## How it works |
| 6 | + |
| 7 | +Operator registers an Cluster in ArgoCD using token generated for service account `argocd-manager`. |
| 8 | + |
| 9 | +Using cluster kubeconfig it creates/patches: |
| 10 | + |
| 11 | +- Namespace `argocd` |
| 12 | +- ServiceAccount `argocd-manager` in namespace `argocd` |
| 13 | +- ClusterRole/ClusterRoleBinding `argocd-manager` letting argocd manage crds, webhooks and rbac resources |
| 14 | + |
| 15 | +## Deployment |
| 16 | + |
| 17 | +### Local |
| 18 | + |
| 19 | +```bash |
| 20 | +skaffold run |
| 21 | +``` |
| 22 | + |
| 23 | +### Management Cluster |
| 24 | + |
| 25 | +```bash |
| 26 | +skaffold build --kube-context <management-cluster> --quiet | \ |
| 27 | +skaffold deploy ---kube-context <management-cluster> --build-artifacts - |
| 28 | +``` |
| 29 | + |
| 30 | +## Operations |
| 31 | + |
| 32 | +### Usage |
| 33 | + |
| 34 | +| Name | Default | Usage | |
| 35 | +| --- | --- | --- | |
| 36 | +| context | | Kubernetes context | |
| 37 | +| health-probe-bind-address | :8081 | The address the probe endpoint binds to | |
| 38 | +| instance | | Instance to populate argocd.fleet.agoda.com/instance annotation | |
| 39 | +| leader-election | true | Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager | |
| 40 | +| metrics-bind-address | :8080 | The address the metric endpoint binds to | |
| 41 | +| token-ttl | 1h0m0s | Service account bearer token TTL | |
| 42 | +| watch-namespaces | [] | Namespaces to watch for Cluster resources | |
| 43 | +| watch-selector | | Selector to watch for Cluster resources | |
| 44 | +| zap-devel | false | Development Mode defaults(encoder=consoleEncoder,logLevel=Debug,stackTraceLevel=Warn). Production Mode defaults(encoder=jsonEncoder,logLevel=Info,stackTraceLevel=Error) | |
| 45 | +| zap-encoder | | Zap log encoding (one of 'json' or 'console') | |
| 46 | +| zap-log-level | | Zap Level to configure the verbosity of logging. Can be one of 'debug', 'info', 'error', or any integer value > 0 which corresponds to custom debug levels of increasing verbosity | |
| 47 | +| zap-stacktrace-level | | Zap Level at and above which stacktraces are captured (one of 'info', 'error', 'panic'). | |
| 48 | +| zap-time-encoding | | Zap time encoding (one of 'epoch', 'millis', 'nano', 'iso8601', 'rfc3339' or 'rfc3339nano'). Defaults to 'epoch'. | |
| 49 | + |
| 50 | +### Cluster discovery |
| 51 | + |
| 52 | +[Cluster](https://doc.crds.dev/github.com/kubernetes-sigs/cluster-api/cluster.x-k8s.io/Cluster/v1beta1@v1.8.3) resources are only watched in namespaces specified by `--watch-namespaces`. |
| 53 | + |
| 54 | +They can be further scoped down by `--watch-filter` which should contain value for `cluster.x-k8s.io/watch-filter` label. |
| 55 | + |
| 56 | +Example: |
| 57 | + |
| 58 | +```yaml |
| 59 | +apiVersion: apps/v1 |
| 60 | +kind: Deployment |
| 61 | +metadata: |
| 62 | + name: argocd-capi-operator |
| 63 | +spec: |
| 64 | + template: |
| 65 | + spec: |
| 66 | + containers: |
| 67 | + - name: operator |
| 68 | + args: |
| 69 | + - --watch-namespaces=kubernetes,tools,nosql |
| 70 | + - --watch-filter=argocd |
| 71 | +``` |
0 commit comments