-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Do Integrate test for Druid base on K8s cluster #10669
Changes from 13 commits
9b3a2ad
3ca937f
1183b70
f215f79
29f1d40
2aef19d
34901b2
3a57cf2
dec7c64
389d890
5d82d88
adf69ab
b7443be
375c253
1a42794
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you 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 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
|
||
# Using For IT on K8s | ||
FROM maven:3-jdk-8-slim as builder | ||
|
||
RUN export DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get -qq update \ | ||
&& apt-get -qq -y install --no-install-recommends python3 python3-yaml | ||
|
||
COPY . /src | ||
WORKDIR /src | ||
|
||
RUN VERSION=$(mvn -B -q org.apache.maven.plugins:maven-help-plugin:3.1.1:evaluate \ | ||
-Dexpression=project.version -DforceStdout=true \ | ||
) \ | ||
&& tar -zxf ./distribution/target/apache-druid-${VERSION}-bin.tar.gz -C /opt \ | ||
&& ln -s /opt/apache-druid-${VERSION} /opt/druid | ||
|
||
FROM amd64/busybox:1.30.0-glibc as busybox | ||
|
||
FROM gcr.io/distroless/java:8 | ||
LABEL maintainer="Apache Druid Developers <dev@druid.apache.org>" | ||
|
||
COPY --from=busybox /bin/busybox /busybox/busybox | ||
RUN ["/busybox/busybox", "--install", "/bin"] | ||
|
||
RUN mkdir -p /shared/wikiticker-it | ||
|
||
COPY examples/quickstart/tutorial/wikiticker-2015-09-12-sampled.json.gz /shared/wikiticker-it/wikiticker-2015-09-12-sampled.json.gz | ||
COPY integration-tests/docker/wiki-simple-lookup.json /shared/wikiticker-it/wiki-simple-lookup.json | ||
|
||
RUN addgroup -S -g 1000 druid \ | ||
&& adduser -S -u 1000 -D -H -h /opt/druid -s /bin/sh -g '' -G druid druid \ | ||
&& mkdir -p /opt/druid/var \ | ||
&& chown -R druid:druid /opt \ | ||
&& chmod 775 /opt/druid/var | ||
|
||
COPY --chown=druid:druid --from=builder /opt /opt | ||
COPY distribution/docker/druid.sh /druid.sh | ||
|
||
USER druid | ||
VOLUME /opt/druid/var | ||
WORKDIR /opt/druid | ||
|
||
ENTRYPOINT ["/druid.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"broker_host" : "localhost", | ||
"broker_port" : "30400", | ||
"broker_tls_url" : "http://localhost:30100", | ||
"router_host" : "localhost", | ||
"router_port" : "30400", | ||
"router_tls_url" : "http://localhost:30400", | ||
"indexer_host" : "localhost", | ||
"indexer_port" : "30400", | ||
"historical_host" : "localhost", | ||
"historical_port" : "30300", | ||
"coordinator_host" : "localhost", | ||
"coordinator_port" : "30400", | ||
"middlemanager_host": "localhost", | ||
"zookeeper_hosts": "localhost:30600" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/env bash | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You 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 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -e | ||
|
||
# setup client keystore | ||
cd integration-tests | ||
./docker/tls/generate-client-certs-and-keystores.sh | ||
rm -rf docker/client_tls | ||
cp -r client_tls docker/client_tls | ||
cd .. | ||
|
||
# Build Docker images for pods | ||
mvn -B -ff -q dependency:go-offline \ | ||
install \ | ||
-Pdist,bundle-contrib-exts \ | ||
-Pskip-static-checks,skip-tests \ | ||
-Dmaven.javadoc.skip=true | ||
|
||
docker build -t druid/cluster:v1 -f distribution/docker/DockerfileBuildTarAdvanced . | ||
|
||
# Set Necessary ENV | ||
export CHANGE_MINIKUBE_NONE_USER=true | ||
export MINIKUBE_WANTUPDATENOTIFICATION=false | ||
export MINIKUBE_WANTREPORTERRORPROMPT=false | ||
export MINIKUBE_HOME=$HOME | ||
export KUBECONFIG=$HOME/.kube/config | ||
sudo apt install -y conntrack | ||
|
||
# This tmp dir is used for MiddleManager pod and Historical Pod to cache segments. | ||
mkdir tmp | ||
chmod 777 tmp | ||
|
||
# Lacunch K8S cluster | ||
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.18.1/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ | ||
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v1.8.1/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/ | ||
sudo /usr/local/bin/minikube start --profile=minikube --vm-driver=none --kubernetes-version=v1.18.1 | ||
sudo /usr/local/bin/minikube update-context | ||
|
||
# Prepare For Druid-Operator | ||
git clone https://github.com/druid-io/druid-operator.git | ||
cd druid-operator | ||
git checkout -b druid-operator-0.0.3 druid-operator-0.0.3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: maybe define There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure thing. Done! |
||
cd .. | ||
sed -i 's|REPLACE_IMAGE|druidio/druid-operator:0.0.3|g' druid-operator/deploy/operator.yaml | ||
cp integration-tests/tiny-cluster.yaml druid-operator/examples/ | ||
cp integration-tests/tiny-cluster-zk.yaml druid-operator/examples/ | ||
Comment on lines
+61
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: not sure why we need to copy, can't we directly use those two files ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are some changes in
So the original files in druid-operator can't be used directly here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry, I wasn't clear, in this context "original" meant files in "integration-tests/" i.e. you have
as opposed to
regardless, it is a nit and doesn't really matter much. |
||
sed -i "s|REPLACE_VOLUMES|`pwd`|g" druid-operator/examples/tiny-cluster.yaml | ||
|
||
# Create ZK, Historical, MiddleManager, Overlord-coordiantor, Broker and Router pods using statefulset | ||
sudo /usr/local/bin/kubectl create -f druid-operator/deploy/service_account.yaml | ||
sudo /usr/local/bin/kubectl create -f druid-operator/deploy/role.yaml | ||
sudo /usr/local/bin/kubectl create -f druid-operator/deploy/role_binding.yaml | ||
sudo /usr/local/bin/kubectl create -f druid-operator/deploy/crds/druid.apache.org_druids_crd.yaml | ||
sudo /usr/local/bin/kubectl create -f druid-operator/deploy/operator.yaml | ||
sudo /usr/local/bin/kubectl apply -f druid-operator/examples/tiny-cluster-zk.yaml | ||
sudo /usr/local/bin/kubectl apply -f druid-operator/examples/tiny-cluster.yaml | ||
|
||
# Wait 4 * 15 seconds to launch pods. | ||
#count=0 | ||
#JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until sudo /usr/local/bin/kubectl -n default get pods -lapp=travis-example -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 4;if [ $count -eq 15 ];then break 2 ;else let "count++";fi;echo $i;echo "waiting for travis-example deployment to be available"; sudo /usr/local/bin/kubectl get pods -n default; done | ||
sleep 120 | ||
|
||
## Debug And FastFail | ||
|
||
sudo /usr/local/bin/kubectl get pod | ||
sudo /usr/local/bin/kubectl get svc | ||
docker images | ||
sudo /usr/local/bin/kubectl describe pod druid-tiny-cluster-middlemanagers-0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You 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 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -e | ||
sudo /usr/local/bin/minikube delete | ||
sudo rm -rf `pwd`/tmp |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You 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 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: tiny-cluster-zk | ||
spec: | ||
clusterIP: None | ||
ports: | ||
- name: zk-client-port | ||
port: 2181 | ||
- name: zk-fwr-port | ||
port: 2888 | ||
- name: zk-elec-port | ||
port: 3888 | ||
selector: | ||
zk_cluster: tiny-cluster-zk | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: tiny-cluster-zk-nodeport | ||
spec: | ||
type: NodePort | ||
ports: | ||
- name: zk-service-port | ||
nodePort: 30600 | ||
port: 2181 | ||
protocol: TCP | ||
targetPort: 2181 | ||
selector: | ||
zk_cluster: tiny-cluster-zk | ||
--- | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
labels: | ||
zk_cluster: tiny-cluster-zk | ||
name: tiny-cluster-zk | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
zk_cluster: tiny-cluster-zk | ||
serviceName: tiny-cluster-zk | ||
template: | ||
metadata: | ||
labels: | ||
zk_cluster: tiny-cluster-zk | ||
spec: | ||
containers: | ||
- env: | ||
- name: ZOO_SERVERS | ||
value: server.0=tiny-cluster-zk-0.tiny-cluster-zk:2888:3888 | ||
- name: SERVER_JVMFLAGS | ||
value: -Xms256m -Xmx256m | ||
image: zookeeper:3.4.13 | ||
name: tiny-cluster-zk | ||
command: ["/bin/sh"] | ||
args: ["-c", "ZOO_MY_ID=$(echo `hostname` | cut -d '-' -f2) /docker-entrypoint.sh zkServer.sh start-foreground"] | ||
ports: | ||
- containerPort: 2181 | ||
name: zk-client-port | ||
- containerPort: 2888 | ||
name: zk-fwr-port | ||
- containerPort: 3888 | ||
name: zk-elec-port | ||
resources: | ||
limits: | ||
cpu: 1 | ||
memory: 512Mi | ||
requests: | ||
cpu: 1 | ||
memory: 512Mi | ||
volumeMounts: | ||
- mountPath: /data | ||
name: druid-test-zk-data | ||
- mountPath: /datalog | ||
name: druid-test-zk-data-log | ||
volumes: | ||
- name: druid-test-zk-data | ||
emptyDir: {} | ||
- name: druid-test-zk-data-log | ||
emptyDir: {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this looks mostly a copy of other Dockerfile , it would be nice to reuse same if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also. There are some changes between
DockerfileBuildTarAdvanced
and originalDockerfile
, such as :Dockerfile
.So that we can't use the original Dockerfile here.