Skip to content

Commit

Permalink
refactor(operators): unify api and design of operators (#187)
Browse files Browse the repository at this point in the history
this is rather radical list, as one can see from amount of changes.
- remove mocks for kubernetes and use fake clients instead
- decople hostname operator from cluster client
- decople ip operator from client
- decople inventory operator from cluster client
- decople metallb operator client from cluster client
- unify operators clients group them within same location
- unify labels and selectors across all operators

Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian authored Feb 12, 2024
1 parent 6ce7931 commit 82c31b7
Show file tree
Hide file tree
Showing 559 changed files with 6,442 additions and 99,274 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ jobs:
- name: K8S dump running pods
working-directory: ${{ env.GOPATH }}/src/github.com/akash-network/provider
run: |
kubectl get pods,ingress,svc -A
kubectl get deployments,pods,ingress,svc -A
- name: K8S wait for operator inventory
working-directory: ${{ env.GOPATH }}/src/github.com/akash-network/provider
run: |
make -s -C _run/kube kube-deployment-rollout-operator-inventory
env:
KUBE_ROLLOUT_TIMEOUT: 360
- name: Run E2E Tests
working-directory: ${{ env.GOPATH }}/src/github.com/akash-network/provider
run: |
Expand Down
45 changes: 45 additions & 0 deletions _docs/kustomize/akash-operator-hostname/cluster-roles.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: akash-operator-hostname
labels:
app.kubernetes.io/name: hostname
app.kubernetes.io/instance: hostname-service
app.kubernetes.io/component: operator
app.kubernetes.io/part-of: provider
rules:
- apiGroups:
- networking.k8s.io
resources:
- ingresses
verbs:
- get
- list
- create
- update
- delete
- deletecollection
- watch
- apiGroups:
- ""
resources:
- namespaces
- services
verbs:
- get
- apiGroups:
- akash.network
resources:
- providerhosts
- manifests
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- pods
verbs:
- get
36 changes: 0 additions & 36 deletions _docs/kustomize/akash-operator-hostname/cluster_role.yaml

This file was deleted.

50 changes: 33 additions & 17 deletions _docs/kustomize/akash-operator-hostname/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,79 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: akash-hostname-operator
name: operator-hostname
labels:
akash.network/component: akash-hostname-operator
app.kubernetes.io/name: hostname
app.kubernetes.io/instance: hostname-service
app.kubernetes.io/component: operator
app.kubernetes.io/part-of: provider
spec:
selector:
matchLabels:
app: akash-hostname-operator
app.kubernetes.io/name: hostname
app.kubernetes.io/instance: hostname-service
app.kubernetes.io/component: operator
app.kubernetes.io/part-of: provider
replicas: 1
revisionHistoryLimit: 1
template:
metadata:
labels:
app: akash-hostname-operator
akash.network/component: akash-hostname-operator
app.kubernetes.io/name: hostname
app.kubernetes.io/instance: hostname-service
app.kubernetes.io/component: operator
app.kubernetes.io/part-of: provider
spec:
serviceAccountName: akash-operator
serviceAccountName: operator-hostname
containers:
- name: akash-hostname-operator
- name: operator-hostname
image: ghcr.io/akash-network/provider:stable
imagePullPolicy: IfNotPresent
args: ["provider-services", "hostname-operator"]
args: ["provider-services", "operator", "hostname"]
ports:
- name: status
containerPort: 8085
- name: rest
containerPort: 8080
env:
- name: AP_K8S_MANIFEST_NS
valueFrom:
configMapKeyRef:
name: akash-provider-config
name: operator-hostname
key: k8s-manifest-ns
- name: AP_PRUNE_INTERVAL
valueFrom:
configMapKeyRef:
name: akash-hostname-operator-config
name: operator-hostname
key: prune-interval
- name: AP_IGNORE_LIST_ENTRY_LIMIT
valueFrom:
configMapKeyRef:
name: akash-hostname-operator-config
name: operator-hostname
key: ignore-list-entry-limit
- name: AP_WEB_REFRESH_INTERVAL
valueFrom:
configMapKeyRef:
name: akash-hostname-operator-config
name: operator-hostname
key: web-refresh-interval
- name: AP_RETRY_DELAY
valueFrom:
configMapKeyRef:
name: akash-hostname-operator-config
name: operator-hostname
key: retry-delay
- name: AP_IGNORE_LIST_AGE_LIMIT
valueFrom:
configMapKeyRef:
name: akash-hostname-operator-config
name: operator-hostname
key: ignore-list-age-limit
- name: AP_EVENT_FAILURE_LIMIT
valueFrom:
configMapKeyRef:
name: akash-hostname-operator-config
name: operator-hostname
key: event-failure-limit
- name: AP_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: AP_POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
10 changes: 4 additions & 6 deletions _docs/kustomize/akash-operator-hostname/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ resources:
- deployment.yaml
- service.yaml
- ingress.yaml
- rbac.yaml
- service_account.yaml
- cluster_role.yaml
- role-bindings.yaml
- service-accounts.yaml
- cluster-roles.yaml
configMapGenerator:
- name: akash-provider-config
- name: operator-hostname
literals:
- k8s-manifest-ns=lease
- name: akash-hostname-operator-config
literals:
- prune-interval=600s
- ignore-list-entry-limit=131072
- web-refresh-interval=5s
Expand Down
49 changes: 0 additions & 49 deletions _docs/kustomize/akash-operator-hostname/rbac.yaml

This file was deleted.

18 changes: 18 additions & 0 deletions _docs/kustomize/akash-operator-hostname/role-bindings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: akash-operator-hostname
labels:
app.kubernetes.io/name: hostname
app.kubernetes.io/instance: hostname-service
app.kubernetes.io/component: operator
app.kubernetes.io/part-of: provider
subjects:
- kind: ServiceAccount
name: operator-hostname
namespace: akash-services
roleRef:
kind: ClusterRole
name: akash-operator-hostname
apiGroup: rbac.authorization.k8s.io
10 changes: 10 additions & 0 deletions _docs/kustomize/akash-operator-hostname/service-accounts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: operator-hostname
labels:
app.kubernetes.io/name: hostname
app.kubernetes.io/instance: hostname-service
app.kubernetes.io/component: operator
app.kubernetes.io/part-of: provider
16 changes: 12 additions & 4 deletions _docs/kustomize/akash-operator-hostname/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@
apiVersion: v1
kind: Service
metadata:
name: akash-hostname-operator
name: operator-hostname
labels:
app.kubernetes.io/name: hostname
app.kubernetes.io/instance: hostname-service
app.kubernetes.io/component: operator
app.kubernetes.io/part-of: provider
spec:
selector:
akash.network/component: akash-hostname-operator
app.kubernetes.io/name: hostname
app.kubernetes.io/instance: hostname-service
app.kubernetes.io/component: operator
app.kubernetes.io/part-of: provider
ports:
- name: status
port: 8085
- name: rest
port: 8080
5 changes: 0 additions & 5 deletions _docs/kustomize/akash-operator-hostname/service_account.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions _docs/kustomize/akash-operator-inventory/cluster-roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: operator-inventory
name: akash-operator-inventory
labels:
akash.network: "true"
app.kubernetes.io/name: inventory
Expand Down Expand Up @@ -94,7 +94,7 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: operator-inventory-hardware-discovery
name: akash-operator-inventory-hardware-discovery
labels:
akash.network: "true"
app.kubernetes.io/name: inventory
Expand Down
28 changes: 14 additions & 14 deletions _docs/kustomize/akash-operator-inventory/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,20 @@ spec:
requests:
cpu: 100m
memory: 128Mi
livenessProbe:
httpGet:
path: /metrics/health
port: api
scheme: HTTP
initialDelaySeconds: 15
periodSeconds: 15
readinessProbe:
httpGet:
path: /metrics/ready
port: api
scheme: HTTP
initialDelaySeconds: 15
periodSeconds: 5
# livenessProbe:
# httpGet:
# path: /metrics/health
# port: api
# scheme: HTTP
# initialDelaySeconds: 15
# periodSeconds: 15
# readinessProbe:
# httpGet:
# path: /metrics/ready
# port: api
# scheme: HTTP
# initialDelaySeconds: 15
# periodSeconds: 5
ports:
- containerPort: 8080
name: api
Expand Down
Loading

0 comments on commit 82c31b7

Please sign in to comment.