Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality for stopping/starting deployment #25

Merged
merged 8 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ CERT_MANAGER := https://github.com/cert-manager/cert-manager/releases/downl
# KUSTOMIZE_VERSION ?= v4.5.7
KUSTOMIZE_VERSION ?= v5.4.3
CTRL_GEN_VERSION ?= v0.16.3
KIND_VERSION ?= v0.22.0
KIND_VERSION ?= v0.24.0
GOLINT_VERSION ?= v1.61.0

.EXPORT_ALL_VARIABLES:
Expand Down Expand Up @@ -85,6 +85,10 @@ manifests: bin/kustomize generate
kustomize build config/certmanager > charts/conduit-operator/templates/certificate.yaml
kustomize build config/webhook > charts/conduit-operator/templates/webhook.yaml

.PHONY: install
install: manifests bin/kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

best to have these installed when the operator boots up, as it will register them automatically.
otherwise there may be discrepancy between crd and code handling the new stuff there.

kustomize build config/crd | kubectl apply -f -

.PHONY: crds
crds: bin/controller-gen
controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ spec:

3. Deploy a sample pipeline configuration
```shell
kubectl apply -f samples/conf/conduit-generator.yaml
kubectl apply -f config/samples/conduit-generator.yaml
```

4. Wait for instance to become ready
Expand Down
22 changes: 15 additions & 7 deletions config/samples/conduit-generator-image-ver.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
apiVersion: operator.conduit.io/v1
apiVersion: operator.conduit.io/v1alpha
kind: Conduit
metadata:
name: conduit-generator
name: conduit-generator-image-ver
spec:
running: true
name: generator.log
description: generator pipeline
image: ghcr.io/conduitio/conduit
version: v0.9.0
version: v0.11.1
connectors:
- name: source-connector
type: source
plugin: builtin:generator
plugin: "builtin:generator"
pluginName: "builtin:generator"
settings:
- name: format.type
value: structured
- name: format.options
value: "id:int,name:string,company:string,trial:bool"
- name: format.options.id
value: "int"
- name: format.options.name
value: "string"
- name: format.options.company
value: "string"
- name: format.options.trial
value: "bool"
- name: recordCount
value: "3"
- name: destination-connector
type: destination
plugin: builtin:log
plugin: "builtin:log"
pluginName: "builtin:log"
2 changes: 1 addition & 1 deletion config/samples/conduit-generator.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: operator.conduit.io/v1
apiVersion: operator.conduit.io/v1alpha
kind: Conduit
metadata:
name: conduit-generator
Expand Down
15 changes: 11 additions & 4 deletions controllers/conduit_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ func (r *ConduitReconciler) CreateOrUpdateVolume(ctx context.Context, c *v1.Cond
// Status conditions are set depending on the outcome of the operation.
func (r *ConduitReconciler) CreateOrUpdateDeployment(ctx context.Context, c *v1.Conduit) error {
var (
cm = corev1.ConfigMap{}
nn = c.NamespacedName()
oneReplica = int32(1)
cm = corev1.ConfigMap{}
nn = c.NamespacedName()
replicas = r.getReplicas(c)

deployment = appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -271,7 +271,7 @@ func (r *ConduitReconciler) CreateOrUpdateDeployment(ctx context.Context, c *v1.
Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RecreateDeploymentStrategyType,
},
Replicas: &oneReplica,
Replicas: &replicas,
Selector: &metav1.LabelSelector{},
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{},
Expand Down Expand Up @@ -456,3 +456,10 @@ func (r *ConduitReconciler) SetupWithManager(mgr ctrl.Manager) error {
// Owns(&corev1.PersistentVolume{}).
Complete(r)
}

func (r *ConduitReconciler) getReplicas(c *v1.Conduit) int32 {
if c.Spec.Running {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a ptr now.

return 1
}
return 0
}