diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index f128e6bb1..000000000 --- a/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -FROM ghcr.io/vmware-research/verifiable-controllers/verus:latest as builder - -WORKDIR /anvil - -SHELL ["/bin/bash", "-c"] - -COPY . . - -# Build the verified zookeeper controller -RUN VERUS_DIR=/verus ./build.sh zookeeper_controller.rs --time -o zookeeper-controller - -# Build the unverified zookeeper controller -# RUN cd reference-controllers/zookeeper-controller && cargo build - -# ============================================================================= - -FROM debian:bullseye-slim - -COPY --from=builder /anvil/src/zookeeper-controller /usr/local/bin/zookeeper-controller -# COPY --from=builder /anvil/reference-controllers/zookeeper-controller/target/debug/zookeeper-controller /usr/local/bin/zookeeper-controller-unverified - -ENTRYPOINT ["/usr/local/bin/zookeeper-controller", "run"] diff --git a/kind-with-registry.sh b/kind-with-registry.sh deleted file mode 100755 index 38b9cc813..000000000 --- a/kind-with-registry.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh -set -o errexit - -# 1. Create registry container unless it already exists -reg_name='kind-registry' -reg_port='5001' -if [ "$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" != 'true' ]; then - docker run \ - -d --restart=always -p "127.0.0.1:${reg_port}:5000" --name "${reg_name}" \ - registry:2 -fi - -# 2. Create kind cluster with containerd registry config dir enabled -# TODO: kind will eventually enable this by default and this patch will -# be unnecessary. -# -# See: -# https://github.com/kubernetes-sigs/kind/issues/2875 -# https://github.com/containerd/containerd/blob/main/docs/cri/config.md#registry-configuration -# See: https://github.com/containerd/containerd/blob/main/docs/hosts.md -cat </dev/null 1>/dev/null - if [[ $? -ne 0 ]]; then - set -e - echo "localhost:${CLIENT_PORT}" - else - set -e - echo "${CLIENT_HOST}:${CLIENT_PORT}" - fi -} \ No newline at end of file diff --git a/reference-controllers/zookeeperLive.sh b/reference-controllers/zookeeperLive.sh deleted file mode 100644 index 20e3ac549..000000000 --- a/reference-controllers/zookeeperLive.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (c) 2018 Dell Inc., or its subsidiaries. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# - -set -ex - -source /conf/env.sh - -OK=$(echo ruok | nc 127.0.0.1 $CLIENT_PORT) - -# Check to see if zookeeper service answers -if [[ "$OK" == "imok" ]]; then - exit 0 - -else - exit 1 - -fi \ No newline at end of file diff --git a/reference-controllers/zookeeperReady.sh b/reference-controllers/zookeeperReady.sh deleted file mode 100644 index ea28876d0..000000000 --- a/reference-controllers/zookeeperReady.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (c) 2018 Dell Inc., or its subsidiaries. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# - -set -ex - -source /conf/env.sh -source /usr/local/bin/zookeeperFunctions.sh - -HOST=`hostname -s` -DATA_DIR=/data -MYID_FILE=$DATA_DIR/myid -LOG4J_CONF=/conf/log4j-quiet.properties -STATIC_CONFIG=/data/conf/zoo.cfg - -OK=$(echo ruok | nc 127.0.0.1 $CLIENT_PORT) - -# Check to see if zookeeper service answers -if [[ "$OK" == "imok" ]]; then - set +e - getent hosts $DOMAIN - if [[ $? -ne 0 ]]; then - set -e - echo "There is no active ensemble, skipping readiness probe..." - exit 0 - else - set -e - # An ensemble exists, check to see if this node is already a member. - # Check to see if zookeeper service for this node is a participant - set +e - # Extract resource name and this members' ordinal value from pod hostname - HOST=`hostname -s` - if [[ $HOST =~ (.*)-([0-9]+)$ ]]; then - NAME=${BASH_REMATCH[1]} - ORD=${BASH_REMATCH[2]} - else - echo Failed to parse name and ordinal of Pod - exit 1 - fi - MYID=$((ORD+1)) - ONDISK_CONFIG=false - if [ -f $MYID_FILE ]; then - EXISTING_ID="`cat $DATA_DIR/myid`" - if [[ "$EXISTING_ID" == "$MYID" && -f $STATIC_CONFIG ]]; then - #If Id is correct and configuration is present under `/data/conf` - ONDISK_CONFIG=true - DYN_CFG_FILE_LINE=`cat $STATIC_CONFIG|grep "dynamicConfigFile\="` - DYN_CFG_FILE=${DYN_CFG_FILE_LINE##dynamicConfigFile=} - SERVER_FOUND=`cat $DYN_CFG_FILE | grep "server.${MYID}=" | wc -l` - if [[ "$SERVER_FOUND" == "0" ]]; then - echo "Server not found in ensemble. Exiting ..." - exit 1 - fi - SERVER=`cat $DYN_CFG_FILE | grep "server.${MYID}="` - if [[ "$SERVER" == *"participant"* ]]; then - ROLE=participant - elif [[ "$SERVER" == *"observer"* ]]; then - ROLE=observer - fi - fi - fi - - if [[ "$ROLE" == "participant" ]]; then - echo "Zookeeper service is available and an active participant" - exit 0 - elif [[ "$ROLE" == "observer" ]]; then - echo "Zookeeper service is ready to be upgraded from observer to participant." - ROLE=participant - ZKURL=$(zkConnectionString) - ZKCONFIG=$(zkConfig) - java -Dlog4j.configuration=file:"$LOG4J_CONF" -jar /opt/libs/zu.jar remove $ZKURL $MYID - sleep 1 - java -Dlog4j.configuration=file:"$LOG4J_CONF" -jar /opt/libs/zu.jar add $ZKURL $MYID $ZKCONFIG - exit 0 - else - echo "Something has gone wrong. Unable to determine zookeeper role." - exit 1 - fi - fi - -else - echo "Zookeeper service is not available for requests" - exit 1 -fi \ No newline at end of file diff --git a/reference-controllers/zookeeperStart.sh b/reference-controllers/zookeeperStart.sh deleted file mode 100644 index 0211ca87d..000000000 --- a/reference-controllers/zookeeperStart.sh +++ /dev/null @@ -1,161 +0,0 @@ -# -# Copyright (c) 2018 Dell Inc., or its subsidiaries. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# - -set -ex - -source /conf/env.sh -source /usr/local/bin/zookeeperFunctions.sh - -HOST=`hostname -s` -DATA_DIR=/data -MYID_FILE=$DATA_DIR/myid -LOG4J_CONF=/conf/log4j-quiet.properties -DYNCONFIG=$DATA_DIR/zoo.cfg.dynamic -STATIC_CONFIG=/data/conf/zoo.cfg - -# Extract resource name and this members ordinal value from pod hostname -if [[ $HOST =~ (.*)-([0-9]+)$ ]]; then - NAME=${BASH_REMATCH[1]} - ORD=${BASH_REMATCH[2]} -else - echo Failed to parse name and ordinal of Pod - exit 1 -fi - -MYID=$((ORD+1)) # = pod order + 1 - -# Values for first startup -WRITE_CONFIGURATION=true -REGISTER_NODE=true -ONDISK_MYID_CONFIG=false -ONDISK_DYN_CONFIG=false - -# Check validity of on-disk configuration -if [ -f $MYID_FILE ]; then - EXISTING_ID="`cat $DATA_DIR/myid`" - if [[ "$EXISTING_ID" == "$MYID" && -f $STATIC_CONFIG ]]; then - # If Id is correct and configuration is present under `/data/conf` - ONDISK_MYID_CONFIG=true - fi -fi - -if [ -f $DYNCONFIG ]; then - ONDISK_DYN_CONFIG=true -fi - -set +e -# Check if envoy is up and running -if [[ -n "$ENVOY_SIDECAR_STATUS" ]]; then - COUNT=0 - MAXCOUNT=${1:-30} - HEALTHYSTATUSCODE="200" - while true; do - COUNT=$(expr $COUNT + 1) - SC=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:15000/ready) - echo "waiting for envoy proxy to come up"; - sleep 1; - if (( "$SC" == "$HEALTHYSTATUSCODE" || "$MAXCOUNT" == "$COUNT" )); then - break - fi - done -fi -set -e - -# Determine if there is an ensemble available to join by checking the service domain -set +e -getent hosts $DOMAIN # This only performs a dns lookup -if [[ $? -eq 0 ]]; then - ACTIVE_ENSEMBLE=true -elif nslookup $DOMAIN | grep -q "server can't find $DOMAIN"; then - echo "there is no active ensemble" - ACTIVE_ENSEMBLE=false -else - # If an nslookup of the headless service domain fails, then there is no - # active ensemble yet, but in certain cases nslookup of headless service - # takes a while to come up even if there is active ensemble - ACTIVE_ENSEMBLE=false - declare -i count=20 - while [[ $count -ge 0 ]] - do - sleep 2 - ((count=count-1)) - getent hosts $DOMAIN - if [[ $? -eq 0 ]]; then - ACTIVE_ENSEMBLE=true - break - fi - done -fi - -if [[ "$ONDISK_MYID_CONFIG" == true && "$ONDISK_DYN_CONFIG" == true ]]; then - # If Configuration is present, we assume, there is no need to write configuration. - WRITE_CONFIGURATION=false -else - WRITE_CONFIGURATION=true -fi - -if [[ "$ACTIVE_ENSEMBLE" == false ]]; then - # This is the first node being added to the cluster or headless service not yet available - REGISTER_NODE=false -else - # An ensemble exists, check to see if this node is already a member. - if [[ "$ONDISK_MYID_CONFIG" == false || "$ONDISK_DYN_CONFIG" == false ]]; then - REGISTER_NODE=true - else - REGISTER_NODE=false - fi -fi - -if [[ "$WRITE_CONFIGURATION" == true ]]; then - echo "Writing myid: $MYID to: $MYID_FILE." - echo $MYID > $MYID_FILE - if [[ $MYID -eq 1 ]]; then - ROLE=participant - echo Initial initialization of ordinal 0 pod, creating new config. - ZKCONFIG=$(zkConfig) - echo Writing bootstrap configuration with the following config: - echo $ZKCONFIG - echo $MYID > $MYID_FILE - echo "server.${MYID}=${ZKCONFIG}" > $DYNCONFIG - fi -fi - -if [[ "$REGISTER_NODE" == true ]]; then - ROLE=observer - ZKURL=$(zkConnectionString) - ZKCONFIG=$(zkConfig) - set -e - echo Registering node and writing local configuration to disk. - java -Dlog4j.configuration=file:"$LOG4J_CONF" -jar /opt/libs/zu.jar add $ZKURL $MYID $ZKCONFIG $DYNCONFIG - set +e -fi - -ZOOCFGDIR=/data/conf -export ZOOCFGDIR -echo Copying /conf contents to writable directory, to support Zookeeper dynamic reconfiguration -if [[ ! -d "$ZOOCFGDIR" ]]; then - mkdir $ZOOCFGDIR - cp -f /conf/zoo.cfg $ZOOCFGDIR -else - echo Copying the /conf/zoo.cfg contents except the dynamic config file during restart - echo -e "$( head -n -1 /conf/zoo.cfg )""\n""$( tail -n 1 "$STATIC_CONFIG" )" > $STATIC_CONFIG -fi -cp -f /conf/log4j.properties $ZOOCFGDIR -cp -f /conf/log4j-quiet.properties $ZOOCFGDIR -cp -f /conf/env.sh $ZOOCFGDIR - -if [ -f $DYNCONFIG ]; then - # Node registered, start server - echo Starting zookeeper service - zkServer.sh --config $ZOOCFGDIR start-foreground -else - echo "Node failed to register!" - exit 1 -fi \ No newline at end of file diff --git a/reference-controllers/zookeeperTeardown.sh b/reference-controllers/zookeeperTeardown.sh deleted file mode 100644 index 517b6a0d6..000000000 --- a/reference-controllers/zookeeperTeardown.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (c) 2018 Dell Inc., or its subsidiaries. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# - -set -ex - -source /conf/env.sh -source /usr/local/bin/zookeeperFunctions.sh - -DATA_DIR=/data -MYID_FILE=$DATA_DIR/myid -LOG4J_CONF=/conf/log4j-quiet.properties - -# Wait for client connections to drain. Kubernetes will wait until the confiugred -# "terminationGracePeriodSeconds" before focibly killing the container -CONN_COUNT=`echo cons | nc localhost 2181 | grep -v "^$" |grep -v "/127.0.0.1:" | wc -l` -for (( i = 0; i < 6; i++ )); do - if [[ "$CONN_COUNT" -gt 0 ]]; then - echo "$CONN_COUNT non-local connections still connected." - sleep 5 - else - echo "$CONN_COUNT non-local connections" - break - fi -done - -# Check to see if zookeeper service for this node is a participant -set +e -ZKURL=$(zkConnectionString) -set -e -MYID=`cat $MYID_FILE` - -ZNODE_PATH="/zookeeper-operator/$CLUSTER_NAME" -CLUSTERSIZE=`java -Dlog4j.configuration=file:"$LOG4J_CONF" -jar /opt/libs/zu.jar sync $ZKURL $ZNODE_PATH` -echo "CLUSTER_SIZE=$CLUSTERSIZE, MyId=$MYID" -if [[ -n "$CLUSTERSIZE" && "$CLUSTERSIZE" -lt "$MYID" ]]; then - # If ClusterSize < MyId, this server is being permanantly removed. - java -Dlog4j.configuration=file:"$LOG4J_CONF" -jar /opt/libs/zu.jar remove $ZKURL $MYID - echo $? -fi - -# Kill the primary process ourselves to circumvent the terminationGracePeriodSeconds -ps -ef | grep zoo.cfg | grep -v grep | awk '{print $2}' | xargs kill \ No newline at end of file diff --git a/src/change_pass.yaml b/src/change_pass.yaml deleted file mode 100644 index e281d09f8..000000000 --- a/src/change_pass.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: rabbitmq.com/v1beta1 -kind: RabbitmqCluster -metadata: - name: myrabbitmq -spec: - rabbitmq: - additionalConfig: | - default_user=ma - default_pass=zi \ No newline at end of file diff --git a/src/cr.yaml b/src/cr.yaml deleted file mode 100644 index c01ae3146..000000000 --- a/src/cr.yaml +++ /dev/null @@ -1,67 +0,0 @@ -apiVersion: rabbitmq.com/v1beta1 -kind: RabbitmqCluster -metadata: - annotations: - kubectl.kubernetes.io/last-applied-configuration: | - {"apiVersion":"rabbitmq.com/v1beta1","kind":"RabbitmqCluster","metadata":{"annotations":{},"name":"hello-world","namespace":"default"}} - creationTimestamp: "2023-06-13T19:00:08Z" - finalizers: - - deletion.finalizers.rabbitmqclusters.rabbitmq.com - generation: 3 - name: hello-world - namespace: default - resourceVersion: "596485" - uid: 5ef34ef9-4f3f-4e43-9360-bf37ad8fcfa8 -spec: - delayStartSeconds: 30 - image: rabbitmq:3.11.18-management - override: {} - persistence: - storage: 10Gi - rabbitmq: {} - replicas: 2 - resources: - limits: - cpu: "2" - memory: 2Gi - requests: - cpu: "1" - memory: 2Gi - secretBackend: - externalSecret: {} - service: - type: ClusterIP - terminationGracePeriodSeconds: 604800 - tls: {} -status: - binding: - name: hello-world-default-user - conditions: - - lastTransitionTime: "2023-06-13T19:01:05Z" - reason: AllPodsAreReady - status: "True" - type: AllReplicasReady - - lastTransitionTime: "2023-06-13T19:01:05Z" - reason: AtLeastOneEndpointAvailable - status: "True" - type: ClusterAvailable - - lastTransitionTime: "2023-06-13T19:00:09Z" - reason: NoWarnings - status: "True" - type: NoWarnings - - lastTransitionTime: "2023-06-13T19:01:07Z" - message: Finish reconciling - reason: Success - status: "True" - type: ReconcileSuccess - defaultUser: - secretReference: - keys: - password: password - username: username - name: hello-world-default-user - namespace: default - serviceReference: - name: hello-world - namespace: default - observedGeneration: 3 diff --git a/src/current.yaml b/src/current.yaml deleted file mode 100644 index 9e51aa6d3..000000000 --- a/src/current.yaml +++ /dev/null @@ -1,71 +0,0 @@ -apiVersion: rabbitmq.com/v1beta1 -kind: RabbitmqCluster -metadata: - annotations: - kubectl.kubernetes.io/last-applied-configuration: | - {"apiVersion":"rabbitmq.com/v1beta1","kind":"RabbitmqCluster","metadata":{"annotations":{},"creationTimestamp":"2023-06-13T19:00:08Z","finalizers":["deletion.finalizers.rabbitmqclusters.rabbitmq.com"],"generation":3,"name":"hello-world","namespace":"default","resourceVersion":"596485","uid":"5ef34ef9-4f3f-4e43-9360-bf37ad8fcfa8"},"spec":{"delayStartSeconds":30,"image":"rabbitmq:3.11.18-management","override":{},"persistence":{"storage":"10Gi"},"rabbitmq":{},"replicas":2,"resources":{"limits":{"cpu":"2","memory":"2Gi"},"requests":{"cpu":"1","memory":"2Gi"}},"secretBackend":{"externalSecret":{}},"service":{"type":"ClusterIP"},"terminationGracePeriodSeconds":604800,"tls":{}},"status":{"binding":{"name":"hello-world-default-user"},"conditions":[{"lastTransitionTime":"2023-06-13T19:01:05Z","reason":"AllPodsAreReady","status":"True","type":"AllReplicasReady"},{"lastTransitionTime":"2023-06-13T19:01:05Z","reason":"AtLeastOneEndpointAvailable","status":"True","type":"ClusterAvailable"},{"lastTransitionTime":"2023-06-13T19:00:09Z","reason":"NoWarnings","status":"True","type":"NoWarnings"},{"lastTransitionTime":"2023-06-13T19:01:07Z","message":"Finish reconciling","reason":"Success","status":"True","type":"ReconcileSuccess"}],"defaultUser":{"secretReference":{"keys":{"password":"password","username":"username"},"name":"hello-world-default-user","namespace":"default"},"serviceReference":{"name":"hello-world","namespace":"default"}},"observedGeneration":3}} - creationTimestamp: "2023-06-13T19:00:08Z" - finalizers: - - deletion.finalizers.rabbitmqclusters.rabbitmq.com - generation: 4 - name: hello-world - namespace: default - resourceVersion: "597153" - uid: 5ef34ef9-4f3f-4e43-9360-bf37ad8fcfa8 -spec: - delayStartSeconds: 30 - image: rabbitmq:3.11.18-management - override: {} - persistence: - storage: 10Gi - rabbitmq: {} - replicas: 2 - rabbitmq: - additionalConfig: | - default_user=guest - default_pass=guest - resources: - limits: - cpu: "2" - memory: 2Gi - requests: - cpu: "1" - memory: 2Gi - secretBackend: - externalSecret: {} - service: - type: ClusterIP - terminationGracePeriodSeconds: 604800 - tls: {} -status: - binding: - name: hello-world-default-user - conditions: - - lastTransitionTime: "2023-06-13T19:06:00Z" - reason: AllPodsAreReady - status: "True" - type: AllReplicasReady - - lastTransitionTime: "2023-06-13T19:05:55Z" - reason: AtLeastOneEndpointAvailable - status: "True" - type: ClusterAvailable - - lastTransitionTime: "2023-06-13T19:00:09Z" - reason: NoWarnings - status: "True" - type: NoWarnings - - lastTransitionTime: "2023-06-13T19:01:07Z" - message: Finish reconciling - reason: Success - status: "True" - type: ReconcileSuccess - defaultUser: - secretReference: - keys: - password: password - username: username - name: hello-world-default-user - namespace: default - serviceReference: - name: hello-world - namespace: default - observedGeneration: 4 diff --git a/src/rabbitmq_crd.yaml b/src/rabbitmq_crd.yaml deleted file mode 100644 index 317f077f4..000000000 --- a/src/rabbitmq_crd.yaml +++ /dev/null @@ -1,61 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: rabbitmqclusters.anvil.dev -spec: - group: anvil.dev - names: - categories: [] - kind: RabbitmqCluster - plural: rabbitmqclusters - shortNames: - - rbmq - singular: rabbitmqcluster - scope: Namespaced - versions: - - additionalPrinterColumns: [] - name: v1 - schema: - openAPIV3Schema: - description: "Auto-generated derived type for RabbitmqClusterSpec via `CustomResource`" - properties: - spec: - properties: - replica: - format: int32 - type: integer - rabbitmq_config: - description: Configuration options for RabbitMQ Pods created in the cluster. - properties: - additionalConfig: - description: Modify to add to the rabbitmq.conf file in addition to default configurations set by the operator. Modifying this property on an existing RabbitmqCluster will trigger a StatefulSet rolling restart and will cause rabbitmq downtime. For more information on this config, see https://www.rabbitmq.com/configure.html#config-file - maxLength: 2000 - type: string - additionalPlugins: - description: 'List of plugins to enable in addition to essential plugins: rabbitmq_management, rabbitmq_prometheus, and rabbitmq_peer_discovery_k8s.' - items: - description: A Plugin to enable on the RabbitmqCluster. - maxLength: 100 - pattern: ^\w+$ - type: string - maxItems: 100 - type: array - advancedConfig: - description: Specify any rabbitmq advanced.config configurations to apply to the cluster. For more information on advanced config, see https://www.rabbitmq.com/configure.html#advanced-config-file - maxLength: 100000 - type: string - envConfig: - description: Modify to add to the rabbitmq-env.conf file. Modifying this property on an existing RabbitmqCluster will trigger a StatefulSet rolling restart and will cause rabbitmq downtime. For more information on env config, see https://www.rabbitmq.com/man/rabbitmq-env.conf.5.html - maxLength: 100000 - type: string - type: object - required: - - replica - type: object - required: - - spec - title: RabbitmqCluster - type: object - served: true - storage: true - subresources: {} \ No newline at end of file diff --git a/src/rbmq.yaml b/src/rbmq.yaml deleted file mode 100644 index 5ec021efe..000000000 --- a/src/rbmq.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: anvil.dev/v1 -kind: RabbitmqCluster -metadata: - name: testz - namespace: default -spec: - replicas: 1 - rabbitmq_config: - additionalConfig: | - default_user=ma - default_pass=zi - log.console.level = debug \ No newline at end of file diff --git a/src/secret.yaml b/src/secret.yaml deleted file mode 100644 index e2444b5b7..000000000 --- a/src/secret.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - name: myrabbitmq-default-user -type: Opaque -stringData: - username: ma - password: zi - default_user.conf: | - default_user = ma - default_pass = zi \ No newline at end of file