Skip to content

Commit

Permalink
fix: rollout working
Browse files Browse the repository at this point in the history
  • Loading branch information
ramantehlan committed Jun 28, 2024
1 parent 34e6d96 commit b7dc393
Show file tree
Hide file tree
Showing 18 changed files with 303 additions and 126 deletions.
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
CONTAINER_TOOL ?= docker

.PHONY: help
help:
@echo "Available targets:"
@awk '/^[a-zA-Z0-9_-]+:.*?##/ { \
nb = index($$0, "##"); \
target = substr($$0, 1, nb - 2); \
helpMsg = substr($$0, nb + 3); \
printf " %-15s %s\n", target, helpMsg; \
}' $(MAKEFILE_LIST) | column -s ':' -t

.PHONY: helm-chart
helm-chart: ## Create Helm chart for the operator
kustomize build operator/config/default | helmify ../charts/elasti

.PHONY: generate-manifest
generate-manifest: ## Generate deploy manifest
kustomize build operator/config/default > ./operator/install.yaml
kustomize build resolver/config/ > ./resolver/install.yaml

.PHONY: deploy
deploy: ## Deploy the operator and resolver
kubectl apply -f ./resolver/install.yaml
kubectl apply -f ./operator/install.yaml

.PHONY: undeploy
undeploy: ## Undeploy the operator and resolver
kubectl delete -f ./resolver/install.yaml
kubectl delete -f ./operator/install.yaml

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ TBA

# Installation / Deployment on K8s

You will be able to install the Elasti Tool by applying the `install.yaml` manifest.
You will be able to install the Elasti Tool by following command
```bash
kubectl install -f install.yaml
make deploy
```

After this, you can start creating elastiService, you can find a sample at `./playground/config/watch-crd.yaml`.
After this, you can start creating elastiService, you can find a sample at `demo-elastiService.yaml`
Please use the exact format.

# Uninstallation

For this, you will need to remove all the CRDs first.
For this, **you will need to remove all the CRDs first. **
Post that, just delete the install file.
```bash
kubectl delete -f install.yaml
make undeploy
```

# Development
Expand Down Expand Up @@ -74,7 +74,7 @@ We will build and publish our resolver changes.
1. Go into resolver directory.
2. Run build and publish command.
```bash
make docker-buildx-resolver IMG=ramantehlan/elasti-resolver:v1alpha1
make docker-buildx IMG=ramantehlan/elasti-resolver:v1alpha1
```

### Build Operator
Expand Down
13 changes: 4 additions & 9 deletions demo-elastiService.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@ metadata:
labels:
app.kubernetes.io/name: elasti-operator
app.kubernetes.io/managed-by: kustomize
name: emotion-class
name: emotion-class-elasti-service
namespace: raman-ws
spec:
queueTimeout: 4
idlePeriod: 20
service: emotion-class-svc
deploymentName: emotion-class-svc
minTargetReplicas: 1
# scaleTargetRef:
# apiVersion: apps/v1
# kind: Rollouts
# name: emotion-class-svc
service: emotion-class-svc
scaleTargetRef:
apiVersion: apps/v1
kind: Deployments
apiVersion: argoproj.io/v1alpha1
kind: rollouts
name: emotion-class-svc

1 change: 0 additions & 1 deletion operator/api/v1alpha1/elastiservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type ElastiServiceSpec struct {
// Important: Run "make" to regenerate code after modifying this file
ScaleTargetRef ScaleTargetRef `json:"scaleTargetRef,omitempty"`
Service string `json:"service,omitempty"`
DeploymentName string `json:"deploymentName,omitempty"`
QTimout int32 `json:"queueTimeout,omitempty"`
IdlePeriod int32 `json:"idlePeriod,omitempty"`
MinTargetReplicas int32 `json:"minTargetReplicas,omitempty"`
Expand Down
9 changes: 4 additions & 5 deletions operator/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ const (
)

func main() {
zapLogger, err := tfLogger.NewLogger("dev")
if err != nil {
setupLog.Error(err, "unable to create logger")
}
var metricsAddr string
var enableLeaderElection bool
var probeAddr string
Expand Down Expand Up @@ -133,11 +137,6 @@ func main() {
os.Exit(1)
}

zapLogger, err := tfLogger.NewLogger("dev")
if err != nil {
setupLog.Error(err, "unable to create logger")
}

// Start the shared CRD Directory
crdDirectory.INITDirectory(zapLogger)
// Initiate and start the shared Informer manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ spec:
spec:
description: ElastiServiceSpec defines the desired state of ElastiService
properties:
deploymentName:
type: string
idlePeriod:
format: int32
type: integer
Expand Down
1 change: 1 addition & 0 deletions operator/config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ spec:
- --health-probe-bind-address=:8081
- --metrics-bind-address=0
image: localhost:5001/elasti-operator:v1alpha1
imagePullPolicy: Always
name: manager
ports:
- containerPort: 8013
Expand Down
6 changes: 5 additions & 1 deletion operator/config/rbac/role_additional.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ rules:
verbs: ["get", "list", "watch", "update", "patch", "delete", "create"]
- apiGroups: [""]
resources: ["services"]
verbs: ["get", "list", "watch", "update", "patch", "delete", "create"]
verbs: ["get", "list", "watch", "update", "patch", "delete", "create"]
- apiGroups: ["argoproj.io"]
resources: ["rollouts"]
verbs: ["get", "list", "watch", "update", "patch"]

18 changes: 17 additions & 1 deletion operator/config/rbac/role_additional_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
labels:
app.kubernetes.io/name: elasti-operator
app.kubernetes.io/managed-by: kustomize
name: additional-access-binding
name: operator-additional-access-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand All @@ -13,3 +13,19 @@ subjects:
- kind: ServiceAccount
name: elasti-operator-controller-manager
namespace: elasti-operator-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
app.kubernetes.io/name: elasti-operator
app.kubernetes.io/managed-by: kustomize
name: resolver-additional-access-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: additional-access
subjects:
- kind: ServiceAccount
name: default
namespace: elasti
Loading

0 comments on commit b7dc393

Please sign in to comment.