From 21c9080121dbc12e619e90cb7832a57c4f99c32e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Elek?= Date: Tue, 11 Dec 2018 16:16:00 +0100 Subject: [PATCH] HDDS-872. Add Dockerfile and skaffold config to deploy ozone dev build to k8s. Contributed by Elek, Marton. --- hadoop-ozone/dist/Dockerfile | 21 +++++ hadoop-ozone/dist/README.md | 85 +++++++++++++++++++ .../dev-support/bin/dist-layout-stitching | 7 ++ hadoop-ozone/dist/skaffold.yaml | 25 ++++++ .../src/main/k8s/ozone/config-configmap.yaml | 34 ++++++++ .../k8s/ozone/datanode-public-service.yaml | 29 +++++++ .../src/main/k8s/ozone/datanode-service.yaml | 29 +++++++ .../main/k8s/ozone/datanode-statefulset.yaml | 52 ++++++++++++ .../src/main/k8s/ozone/om-public-service.yaml | 29 +++++++ .../dist/src/main/k8s/ozone/om-service.yaml | 29 +++++++ .../src/main/k8s/ozone/om-statefulset.yaml | 72 ++++++++++++++++ .../main/k8s/ozone/s3g-public-service.yaml | 29 +++++++ .../dist/src/main/k8s/ozone/s3g-service.yaml | 29 +++++++ .../src/main/k8s/ozone/s3g-statefulset.yaml | 49 +++++++++++ .../main/k8s/ozone/scm-public-service.yaml | 29 +++++++ .../dist/src/main/k8s/ozone/scm-service.yaml | 29 +++++++ .../src/main/k8s/ozone/scm-statefulset.yaml | 67 +++++++++++++++ .../src/main/k8s/prometheus/configmap.yaml | 51 +++++++++++ .../src/main/k8s/prometheus/deployment.yaml | 46 ++++++++++ .../prometheus/prometheus-public-serivce.yaml | 28 ++++++ .../dist/src/main/k8s/prometheus/role.yaml | 31 +++++++ .../src/main/k8s/prometheus/rolebindng.yaml | 27 ++++++ .../k8s/prometheus/scm-public-service.yaml | 29 +++++++ .../main/k8s/prometheus/service-account.yaml | 19 +++++ .../dist/src/main/k8s/prometheus/service.yaml | 25 ++++++ 25 files changed, 900 insertions(+) create mode 100644 hadoop-ozone/dist/Dockerfile create mode 100644 hadoop-ozone/dist/README.md create mode 100644 hadoop-ozone/dist/skaffold.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/ozone/config-configmap.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/ozone/datanode-public-service.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/ozone/datanode-service.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/ozone/datanode-statefulset.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/ozone/om-public-service.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/ozone/om-service.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/ozone/om-statefulset.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/ozone/s3g-public-service.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/ozone/s3g-service.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/ozone/s3g-statefulset.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/ozone/scm-public-service.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/ozone/scm-service.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/ozone/scm-statefulset.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/prometheus/configmap.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/prometheus/deployment.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/prometheus/prometheus-public-serivce.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/prometheus/role.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/prometheus/rolebindng.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/prometheus/scm-public-service.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/prometheus/service-account.yaml create mode 100644 hadoop-ozone/dist/src/main/k8s/prometheus/service.yaml diff --git a/hadoop-ozone/dist/Dockerfile b/hadoop-ozone/dist/Dockerfile new file mode 100644 index 00000000000..c22c3ca913c --- /dev/null +++ b/hadoop-ozone/dist/Dockerfile @@ -0,0 +1,21 @@ +# 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. + +FROM apache/hadoop-runner:latest + +ADD --chown=hadoop target/ozone-0.4.0-SNAPSHOT /opt/hadoop + +WORKDIR /opt/hadoop diff --git a/hadoop-ozone/dist/README.md b/hadoop-ozone/dist/README.md new file mode 100644 index 00000000000..88132ec1728 --- /dev/null +++ b/hadoop-ozone/dist/README.md @@ -0,0 +1,85 @@ + + +# Ozone Distribution + +This folder contains the project to create the binary ozone distribution and provide all the helper script and docker files to start it locally or in the cluster. + +## Testing with local docker based cluster + +After a full dist build you can find multiple docker-compose based cluster definition in the `target/ozone-*/compose` folder. + +Please check the README files there. + +Usually you can start the cluster with: + +``` +cd compose/ozone +docker-compose up -d +``` + +## Testing on Kubernetes + +You can also test the ozone cluster in kubernetes. If you have no active kubernetes cluster you can start a local one with minikube: + +``` +minikube start +``` + +For testing in kubernetes you need to: + +1. Create a docker image with the new build +2. Upload it to a docker registery +3. Deploy the cluster with apply kubernetes resources + +The easiest way to do all these steps is using the [skaffold](https://github.com/GoogleContainerTools/skaffold) tool. After the [installation of skaffold](https://github.com/GoogleContainerTools/skaffold#installation), you can execute + +``` +skaffold run +``` + +in this (`hadoop-ozone/dist`) folder. + +The default kubernetes resources set (`src/main/k8s/`) contains NodePort based service definitions for the Ozone Manager, Storage Container Manager and the S3 gateway. + +With minikube you can access the services with: + +``` +minikube service s3g-public +minikube service om-public +minikube service scm-public +``` + +### Monitoring + +Apache Hadoop Ozone supports Prometheus out-of the box. It contains a prometheus compatible exporter servlet. To start the monitoring you need a prometheus deploy in your kubernetes cluster: + +``` +cd src/main/k8s/prometheus +kubectl apply -f . +``` + +The prometheus ui also could be access via a NodePort service: + +``` +minikube service prometheus-public +``` + +### Notes on the Kubernetes setup + +Please not that the provided kubernetes resources are not suitable production: + +1. There are no security setup +2. The datanode is started in StatefulSet instead of DaemonSet (To make it possible to scale it up on one node minikube cluster) +3. All the UI pages are published with NodePort services \ No newline at end of file diff --git a/hadoop-ozone/dist/dev-support/bin/dist-layout-stitching b/hadoop-ozone/dist/dev-support/bin/dist-layout-stitching index e7360651f32..73716c45614 100755 --- a/hadoop-ozone/dist/dev-support/bin/dist-layout-stitching +++ b/hadoop-ozone/dist/dev-support/bin/dist-layout-stitching @@ -71,6 +71,13 @@ run mkdir -p ./share/hadoop/hdds run mkdir -p ./share/hadoop/yarn run mkdir -p ./share/hadoop/hdfs run mkdir -p ./share/hadoop/common + +touch ./share/hadoop/mapreduce/.keep +touch ./share/hadoop/yarn/.keep +touch ./share/hadoop/hdfs/.keep +touch ./share/hadoop/common/.keep + + run mkdir -p ./share/ozone/web run mkdir -p ./bin run mkdir -p ./sbin diff --git a/hadoop-ozone/dist/skaffold.yaml b/hadoop-ozone/dist/skaffold.yaml new file mode 100644 index 00000000000..cb5f375c34d --- /dev/null +++ b/hadoop-ozone/dist/skaffold.yaml @@ -0,0 +1,25 @@ +# 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: skaffold/v1alpha5 +kind: Config +build: + artifacts: + - image: apache/ozone +deploy: + kubectl: + manifests: + - src/main/k8s/ozone/* diff --git a/hadoop-ozone/dist/src/main/k8s/ozone/config-configmap.yaml b/hadoop-ozone/dist/src/main/k8s/ozone/config-configmap.yaml new file mode 100644 index 00000000000..e79a3cc9058 --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/ozone/config-configmap.yaml @@ -0,0 +1,34 @@ +# 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: ConfigMap +metadata: + name: config + labels: {} + annotations: {} +data: + OZONE-SITE.XML_ozone.scm.datanode.id: "/data/datanode.id" + OZONE-SITE.XML_ozone.metadata.dirs: "/data/metadata" + OZONE-SITE.XML_ozone.scm.block.client.address: "scm-0.scm" + OZONE-SITE.XML_ozone.om.address: "om-0.om" + OZONE-SITE.XML_ozone.scm.client.address: "scm-0.scm" + OZONE-SITE.XML_ozone.scm.names: "scm-0.scm" + OZONE-SITE.XML_ozone.enabled: "true" + OZONE-SITE.XML_hdds.prometheus.endpoint.enabled: "true" + LOG4J.PROPERTIES_log4j.rootLogger: "INFO, stdout" + LOG4J.PROPERTIES_log4j.appender.stdout: "org.apache.log4j.ConsoleAppender" + LOG4J.PROPERTIES_log4j.appender.stdout.layout: "org.apache.log4j.PatternLayout" + LOG4J.PROPERTIES_log4j.appender.stdout.layout.ConversionPattern: "%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" diff --git a/hadoop-ozone/dist/src/main/k8s/ozone/datanode-public-service.yaml b/hadoop-ozone/dist/src/main/k8s/ozone/datanode-public-service.yaml new file mode 100644 index 00000000000..22154b76c97 --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/ozone/datanode-public-service.yaml @@ -0,0 +1,29 @@ +# 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: datanode-public + labels: {} + annotations: {} +spec: + selector: + app: ozone + component: datanode + ports: + - port: 9870 + name: rpc + type: NodePort diff --git a/hadoop-ozone/dist/src/main/k8s/ozone/datanode-service.yaml b/hadoop-ozone/dist/src/main/k8s/ozone/datanode-service.yaml new file mode 100644 index 00000000000..bdc8009712b --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/ozone/datanode-service.yaml @@ -0,0 +1,29 @@ +# 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: datanode + labels: {} + annotations: {} +spec: + clusterIP: None + selector: + app: ozone + component: datanode + ports: + - port: 9870 + name: rpc diff --git a/hadoop-ozone/dist/src/main/k8s/ozone/datanode-statefulset.yaml b/hadoop-ozone/dist/src/main/k8s/ozone/datanode-statefulset.yaml new file mode 100644 index 00000000000..f8600a07008 --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/ozone/datanode-statefulset.yaml @@ -0,0 +1,52 @@ +# 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: apps/v1 +kind: StatefulSet +metadata: + name: datanode + labels: {} + annotations: {} +spec: + selector: + matchLabels: + app: ozone + component: datanode + template: + metadata: + labels: + app: ozone + component: datanode + spec: + containers: + - name: datanode + image: apache/ozone + args: + - ozone + - datanode + ports: + - containerPort: 9870 + name: rpc + volumeMounts: + - name: "data" + mountPath: "/data" + envFrom: + - configMapRef: + name: config + volumes: + - name: "data" + emptyDir: {} + serviceName: datanode + replicas: 3 diff --git a/hadoop-ozone/dist/src/main/k8s/ozone/om-public-service.yaml b/hadoop-ozone/dist/src/main/k8s/ozone/om-public-service.yaml new file mode 100644 index 00000000000..a150939c728 --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/ozone/om-public-service.yaml @@ -0,0 +1,29 @@ +# 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: om-public + labels: {} + annotations: {} +spec: + ports: + - port: 9874 + name: ui + selector: + app: ozone + component: om + type: NodePort diff --git a/hadoop-ozone/dist/src/main/k8s/ozone/om-service.yaml b/hadoop-ozone/dist/src/main/k8s/ozone/om-service.yaml new file mode 100644 index 00000000000..f363c48ead0 --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/ozone/om-service.yaml @@ -0,0 +1,29 @@ +# 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: om + labels: {} + annotations: {} +spec: + ports: + - port: 9874 + name: ui + clusterIP: None + selector: + app: ozone + component: om diff --git a/hadoop-ozone/dist/src/main/k8s/ozone/om-statefulset.yaml b/hadoop-ozone/dist/src/main/k8s/ozone/om-statefulset.yaml new file mode 100644 index 00000000000..08d6089dd2b --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/ozone/om-statefulset.yaml @@ -0,0 +1,72 @@ +# 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: apps/v1 +kind: StatefulSet +metadata: + name: om + labels: {} + annotations: {} +spec: + selector: + matchLabels: + app: ozone + component: om + serviceName: om + replicas: 1 + template: + metadata: + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "9874" + prometheus.io/path: "/prom" + labels: + app: ozone + component: om + spec: + initContainers: + - name: init + image: apache/ozone + args: + - ozone + - om + - --init + env: + - name: "WAITFOR" + value: "scm-0.scm:9876" + volumeMounts: + - name: "data" + mountPath: "/data" + envFrom: + - configMapRef: + name: config + containers: + - name: om + image: apache/ozone + args: + - ozone + - om + env: + - name: "WAITFOR" + value: "scm-0.scm:9876" + volumeMounts: + - name: "data" + mountPath: "/data" + envFrom: + - configMapRef: + name: config + volumes: + - name: "data" + emptyDir: {} diff --git a/hadoop-ozone/dist/src/main/k8s/ozone/s3g-public-service.yaml b/hadoop-ozone/dist/src/main/k8s/ozone/s3g-public-service.yaml new file mode 100644 index 00000000000..54d10de2b52 --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/ozone/s3g-public-service.yaml @@ -0,0 +1,29 @@ +# 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: s3g-public + labels: {} + annotations: {} +spec: + ports: + - port: 9878 + name: rest + selector: + app: ozone + component: s3g + type: NodePort diff --git a/hadoop-ozone/dist/src/main/k8s/ozone/s3g-service.yaml b/hadoop-ozone/dist/src/main/k8s/ozone/s3g-service.yaml new file mode 100644 index 00000000000..8441e12a75a --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/ozone/s3g-service.yaml @@ -0,0 +1,29 @@ +# 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: s3g + labels: {} + annotations: {} +spec: + ports: + - port: 9878 + name: rest + clusterIP: None + selector: + app: ozone + component: s3g diff --git a/hadoop-ozone/dist/src/main/k8s/ozone/s3g-statefulset.yaml b/hadoop-ozone/dist/src/main/k8s/ozone/s3g-statefulset.yaml new file mode 100644 index 00000000000..dd6fc257d52 --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/ozone/s3g-statefulset.yaml @@ -0,0 +1,49 @@ +# 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: apps/v1 +kind: StatefulSet +metadata: + name: s3g + labels: {} + annotations: {} +spec: + selector: + matchLabels: + app: ozone + component: s3g + serviceName: s3g + replicas: 1 + template: + metadata: + labels: + app: ozone + component: s3g + spec: + containers: + - name: s3g + image: apache/ozone + args: + - ozone + - s3g + volumeMounts: + - name: "data" + mountPath: "/data" + envFrom: + - configMapRef: + name: config + volumes: + - name: "data" + emptyDir: {} diff --git a/hadoop-ozone/dist/src/main/k8s/ozone/scm-public-service.yaml b/hadoop-ozone/dist/src/main/k8s/ozone/scm-public-service.yaml new file mode 100644 index 00000000000..ddfe138d110 --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/ozone/scm-public-service.yaml @@ -0,0 +1,29 @@ +# 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: scm-public + labels: {} + annotations: {} +spec: + ports: + - port: 9876 + name: ui + selector: + app: ozone + component: scm + type: NodePort diff --git a/hadoop-ozone/dist/src/main/k8s/ozone/scm-service.yaml b/hadoop-ozone/dist/src/main/k8s/ozone/scm-service.yaml new file mode 100644 index 00000000000..f3116957954 --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/ozone/scm-service.yaml @@ -0,0 +1,29 @@ +# 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: scm + labels: {} + annotations: {} +spec: + ports: + - port: 9876 + name: ui + clusterIP: None + selector: + app: ozone + component: scm diff --git a/hadoop-ozone/dist/src/main/k8s/ozone/scm-statefulset.yaml b/hadoop-ozone/dist/src/main/k8s/ozone/scm-statefulset.yaml new file mode 100644 index 00000000000..80c59242dab --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/ozone/scm-statefulset.yaml @@ -0,0 +1,67 @@ +# 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: apps/v1 +kind: StatefulSet +metadata: + name: scm + labels: {} + annotations: {} +spec: + selector: + matchLabels: + app: ozone + component: scm + serviceName: scm + replicas: 1 + template: + metadata: + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "9876" + prometheus.io/path: "/prom" + labels: + app: ozone + component: scm + spec: + initContainers: + - name: init + image: apache/ozone + args: + - ozone + - scm + - --init + env: [] + volumeMounts: + - name: "data" + mountPath: "/data" + envFrom: + - configMapRef: + name: config + containers: + - name: scm + image: apache/ozone + args: + - ozone + - scm + volumeMounts: + - name: "data" + mountPath: "/data" + envFrom: + - configMapRef: + name: config + volumes: + - name: "data" + emptyDir: {} diff --git a/hadoop-ozone/dist/src/main/k8s/prometheus/configmap.yaml b/hadoop-ozone/dist/src/main/k8s/prometheus/configmap.yaml new file mode 100644 index 00000000000..40b13e23d02 --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/prometheus/configmap.yaml @@ -0,0 +1,51 @@ +# 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: ConfigMap +metadata: + name: prometheusconf +data: + prometheus.yaml: |- + global: + scrape_interval: 15s + scrape_configs: + - job_name: jmxexporter + kubernetes_sd_configs: + - role: pod + namespaces: + names: ["default"] + bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token + relabel_configs: + - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape] + action: keep + regex: true + - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path] + action: replace + target_label: __metrics_path__ + regex: (.+) + - source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port] + action: replace + regex: ([^:]+)(?::\d+)?;(\d+) + replacement: $1:$2 + target_label: __address__ + - action: labelmap + regex: __meta_kubernetes_pod_label_(.+) + - source_labels: [__meta_kubernetes_namespace] + action: replace + target_label: kubernetes_namespace + - source_labels: [__meta_kubernetes_pod_name] + action: replace + target_label: kubernetes_pod_name diff --git a/hadoop-ozone/dist/src/main/k8s/prometheus/deployment.yaml b/hadoop-ozone/dist/src/main/k8s/prometheus/deployment.yaml new file mode 100644 index 00000000000..636840398ee --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/prometheus/deployment.yaml @@ -0,0 +1,46 @@ +# 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: apps/v1beta1 +kind: Deployment +metadata: + name: prometheus + labels: + app: prometheus +spec: + replicas: 1 + selector: + matchLabels: + app: prometheus + template: + metadata: + labels: + app: prometheus + spec: + serviceAccountName: prometheus-operator + containers: + - name: prometheus + image: prom/prometheus + args: ["--config.file=/conf/prometheus.yaml"] + ports: + - containerPort: 9090 + volumeMounts: + - name: config + mountPath: "/conf" + readOnly: true + volumes: + - name: config + configMap: + name: prometheusconf diff --git a/hadoop-ozone/dist/src/main/k8s/prometheus/prometheus-public-serivce.yaml b/hadoop-ozone/dist/src/main/k8s/prometheus/prometheus-public-serivce.yaml new file mode 100644 index 00000000000..276943dccbe --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/prometheus/prometheus-public-serivce.yaml @@ -0,0 +1,28 @@ +# 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: prometheus-public + labels: {} + annotations: {} +spec: + ports: + - port: 9090 + name: ui + selector: + app: prometheus + type: NodePort diff --git a/hadoop-ozone/dist/src/main/k8s/prometheus/role.yaml b/hadoop-ozone/dist/src/main/k8s/prometheus/role.yaml new file mode 100644 index 00000000000..e9412faff82 --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/prometheus/role.yaml @@ -0,0 +1,31 @@ +# 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: rbac.authorization.k8s.io/v1beta1 +kind: Role +metadata: + name: prometheus +rules: +- apiGroups: [""] + resources: + - nodes + - services + - endpoints + - pods + verbs: ["get", "list", "watch"] +- apiGroups: [""] + resources: + - configmaps + verbs: ["get"] diff --git a/hadoop-ozone/dist/src/main/k8s/prometheus/rolebindng.yaml b/hadoop-ozone/dist/src/main/k8s/prometheus/rolebindng.yaml new file mode 100644 index 00000000000..ffd340d28e4 --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/prometheus/rolebindng.yaml @@ -0,0 +1,27 @@ +# 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: rbac.authorization.k8s.io/v1beta1 +kind: RoleBinding +metadata: + name: prometheus-operator +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: prometheus +subjects: +- kind: ServiceAccount + name: prometheus-operator +# namespace: default diff --git a/hadoop-ozone/dist/src/main/k8s/prometheus/scm-public-service.yaml b/hadoop-ozone/dist/src/main/k8s/prometheus/scm-public-service.yaml new file mode 100644 index 00000000000..ddfe138d110 --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/prometheus/scm-public-service.yaml @@ -0,0 +1,29 @@ +# 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: scm-public + labels: {} + annotations: {} +spec: + ports: + - port: 9876 + name: ui + selector: + app: ozone + component: scm + type: NodePort diff --git a/hadoop-ozone/dist/src/main/k8s/prometheus/service-account.yaml b/hadoop-ozone/dist/src/main/k8s/prometheus/service-account.yaml new file mode 100644 index 00000000000..d5ba196c747 --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/prometheus/service-account.yaml @@ -0,0 +1,19 @@ +# 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: ServiceAccount +metadata: + name: prometheus-operator diff --git a/hadoop-ozone/dist/src/main/k8s/prometheus/service.yaml b/hadoop-ozone/dist/src/main/k8s/prometheus/service.yaml new file mode 100644 index 00000000000..e07aafc1869 --- /dev/null +++ b/hadoop-ozone/dist/src/main/k8s/prometheus/service.yaml @@ -0,0 +1,25 @@ +# 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. +kind: Service +apiVersion: v1 +metadata: + name: prometheus +spec: + selector: + app: prometheus + ports: + - protocol: TCP + port: 9090