Skip to content

Commit

Permalink
Update Cassandra image to include LDAP and Kerberos plugins. (#155)
Browse files Browse the repository at this point in the history
* Work in progress support for LDAP and Kerberos plugins.

* Update Cassandra image to include LDAP and Kerberos plugins.
Modify Makefiles to support repo-less Docker builds.
  • Loading branch information
zegelin authored and benbromhead committed Apr 24, 2019
1 parent 207b7a8 commit b70f0cb
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 12 deletions.
2 changes: 1 addition & 1 deletion buildenv/build-all
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

cd `dirname "$BASH_SOURCE"`/..

export DOCKER_REPO="${REPO:-gcr.io/cassandra-operator}"
export DOCKER_REPO="${REPO:-gcr.io/cassandra-operator}/"

cd docker
make
Expand Down
4 changes: 2 additions & 2 deletions docker/base-openjre/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
OPENJRE_VERSION := "8u181-b13-2~deb9u1"
OPENJRE_IMAGE_TAG := stretch-$(subst ~,-,$(OPENJRE_VERSION))
OPENJRE_IMAGE := $(DOCKER_REPO)/base-openjre:$(OPENJRE_IMAGE_TAG)
OPENJRE_IMAGE := $(DOCKER_REPO)base-openjre:$(OPENJRE_IMAGE_TAG)

.PHONY: base-openjre
base-openjre:
docker build \
--build-arg openjre_version=$(OPENJRE_VERSION) \
-t $(DOCKER_REPO)/base-openjre \
-t $(DOCKER_REPO)base-openjre \
-t $(OPENJRE_IMAGE) \
.

Expand Down
4 changes: 2 additions & 2 deletions docker/cassandra-operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ cassandra-operator: $(CASSANDRA_OPERATOR_JAR)
docker build \
--build-arg cassandra_operator_jar=$(CASSANDRA_OPERATOR_JAR) \
--build-arg openjre_image="$(OPENJRE_IMAGE)" \
-t $(DOCKER_REPO)/cassandra-operator \
-t $(DOCKER_REPO)/cassandra-operator:$(CASSANDRA_OPERATOR_VERSION) \
-t $(DOCKER_REPO)cassandra-operator \
-t $(DOCKER_REPO)cassandra-operator:$(CASSANDRA_OPERATOR_VERSION) \
.

.PHONY: clean
Expand Down
7 changes: 4 additions & 3 deletions docker/cassandra-sidecar/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ CASSANDRA_SIDECAR_VERSION := 1.0-SNAPSHOT
CASSANDRA_SIDECAR_JAR := cassandra-sidecar-$(CASSANDRA_SIDECAR_VERSION).jar

ifeq ($(CASSANDRA_SIDECAR_VERSION:%-SNAPSHOT=SNAPSHOT),SNAPSHOT)
$(info SNAPSHOT version specified. Marking JAR target as .PHONY)
# mark sidecar-jar target as .PHONY to force a re-copy on every build
$(info cassandra-sidecar SNAPSHOT version specified ($(CASSANDRA_SIDECAR_VERSION)). Marking JAR target as .PHONY. This will re-download the artifact.)
.PHONY: $(CASSANDRA_SIDECAR_JAR)
endif

Expand All @@ -16,8 +17,8 @@ cassandra-sidecar: $(CASSANDRA_SIDECAR_JAR)
docker build \
--build-arg cassandra_sidecar_jar=$(CASSANDRA_SIDECAR_JAR) \
--build-arg openjre_image="$(OPENJRE_IMAGE)" \
-t $(DOCKER_REPO)/cassandra-sidecar \
-t $(DOCKER_REPO)/cassandra-sidecar:$(CASSANDRA_SIDECAR_VERSION) \
-t $(DOCKER_REPO)cassandra-sidecar \
-t $(DOCKER_REPO)cassandra-sidecar:$(CASSANDRA_SIDECAR_VERSION) \
.

.PHONY: clean
Expand Down
14 changes: 10 additions & 4 deletions docker/cassandra/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,30 @@ CASSANDRA_VERSION := 3.11.3
CASSANDRA_K8S_ADDONS_VERSION := 1.0-SNAPSHOT
CASSANDRA_K8S_ADDONS_JAR := cassandra-k8s-addons-$(CASSANDRA_K8S_ADDONS_VERSION).jar


# Cassandra/K8s Addons
ifeq ($(CASSANDRA_K8S_ADDONS_VERSION:%-SNAPSHOT=SNAPSHOT),SNAPSHOT)
$(info SNAPSHOT version specified. Marking JAR target as .PHONY)
# mark addons-jar target as .PHONY to force a re-copy on every build
$(info cassandra-k8s-addons SNAPSHOT version specified ($(CASSANDRA_K8S_ADDONS_VERSION)). Marking JAR target as .PHONY. This will re-download the artifact.)
.PHONY: $(CASSANDRA_K8S_ADDONS_JAR)
endif

$(CASSANDRA_K8S_ADDONS_JAR):
mvn dependency:copy -Dartifact=com.instaclustr.cassandra-operator:cassandra-k8s-addons:$(CASSANDRA_K8S_ADDONS_VERSION) -DoutputDirectory=. -Dmdep.stripClassifier=true



# Cassandra
.PHONY: cassandra
cassandra: $(CASSANDRA_K8S_ADDONS_JAR)
docker build \
--build-arg cassandra_version=$(CASSANDRA_VERSION) \
--build-arg cassandra_k8s_addons_jar=$(CASSANDRA_K8S_ADDONS_JAR) \
--build-arg openjre_image="$(OPENJRE_IMAGE)" \
-t $(DOCKER_REPO)/cassandra \
-t $(DOCKER_REPO)/cassandra:$(CASSANDRA_VERSION) \
-t $(DOCKER_REPO)cassandra \
-t $(DOCKER_REPO)cassandra:$(CASSANDRA_VERSION) \
.


.PHONY: clean
clean:
rm $(CASSANDRA_K8S_ADDONS_JAR)
Expand Down
54 changes: 54 additions & 0 deletions docker/cassandra/install-cassandra
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
#!/bin/bash -xue

echoerr() { >&2 echo $@; }

cassandra_version=$1

case $cassandra_version in
3.*)
# supported
;;

2.*)
# 2.2 pulls in openjre, which pulls in gtk, x11, etc.
# also, the default-config is specific to 3.11.x.
# 2.2 fails to start due to unrecognised YAML properties.

# no k8s addons support, yet.
;&

*)
echoerr "WARNING: Cassandra version ${cassandra_version} is unsupported."
exit 1;
esac

adduser --disabled-password --gid 0 --gecos "Cassandra" cassandra

pkg_dir=$(mktemp -d) && chmod 755 "${pkg_dir}"
Expand Down Expand Up @@ -42,6 +62,40 @@ mkdir /etc/cassandra/logback.xml.d
curl -SLO "https://github.com/instaclustr/cassandra-exporter/releases/download/v0.9.6/cassandra-exporter-agent-0.9.6.jar" &&
ln -s cassandra-exporter-agent-0.9.6.jar cassandra-exporter-agent.jar)

# install Instaclustr LDAP and Kerberos authn/authz plugins
(
cd "/usr/share/cassandra/lib"

# TODO: switch remaining Maven Central URLs to GitHub.
case ${cassandra_version} in
3.11.*)
curl -SLO "https://github.com/instaclustr/cassandra-ldap/releases/download/3.11.4.4/cassandra-ldap-3.11.4.jar"
;;
3.0.*)
curl -SLO "https://search.maven.org/remotecontent?filepath=com/instaclustr/cassandra-ldap/3.0.18.0/cassandra-ldap-3.0.18.0.jar"
;;
2.2.*)
curl -SLO "https://search.maven.org/remotecontent?filepath=com/instaclustr/cassandra-ldap/2.2.14.0/cassandra-ldap-2.2.14.jar"
;;
*)
echoerr "WARNING: No LDAP plugin available for Cassandra version ${cassandra_version}. This feature will be unavailable."
;;
esac

case ${cassandra_version} in
3.11.*)
curl -SLO "https://github.com/instaclustr/cassandra-kerberos/releases/download/v1.0.0-cassandra-3.11/cassandra-3-11-kerberos-1.0.0.jar"
;;
3.0.*)
curl -SLO "https://github.com/instaclustr/cassandra-kerberos/releases/download/v1.0.0-cassandra-3.0/cassandra-3-0-kerberos-1.0.0.jar"
;;
*)
echoerr "WARNING: No Kerberos plugin available for Cassandra version ${cassandra_version}. This feature will be unavailable."
;;
esac
)


# clean-up
rm -rf "${pkg_dir}"
apt-get -y remove dpkg-dev && apt-get -y autoremove
Expand Down

0 comments on commit b70f0cb

Please sign in to comment.