Просмотр исходного кода

HDDS-872. Add Dockerfile and skaffold config to deploy ozone dev build to k8s. Contributed by Elek, Marton.

Márton Elek 6 лет назад
Родитель
Сommit
21c9080121
25 измененных файлов с 900 добавлено и 0 удалено
  1. 21 0
      hadoop-ozone/dist/Dockerfile
  2. 85 0
      hadoop-ozone/dist/README.md
  3. 7 0
      hadoop-ozone/dist/dev-support/bin/dist-layout-stitching
  4. 25 0
      hadoop-ozone/dist/skaffold.yaml
  5. 34 0
      hadoop-ozone/dist/src/main/k8s/ozone/config-configmap.yaml
  6. 29 0
      hadoop-ozone/dist/src/main/k8s/ozone/datanode-public-service.yaml
  7. 29 0
      hadoop-ozone/dist/src/main/k8s/ozone/datanode-service.yaml
  8. 52 0
      hadoop-ozone/dist/src/main/k8s/ozone/datanode-statefulset.yaml
  9. 29 0
      hadoop-ozone/dist/src/main/k8s/ozone/om-public-service.yaml
  10. 29 0
      hadoop-ozone/dist/src/main/k8s/ozone/om-service.yaml
  11. 72 0
      hadoop-ozone/dist/src/main/k8s/ozone/om-statefulset.yaml
  12. 29 0
      hadoop-ozone/dist/src/main/k8s/ozone/s3g-public-service.yaml
  13. 29 0
      hadoop-ozone/dist/src/main/k8s/ozone/s3g-service.yaml
  14. 49 0
      hadoop-ozone/dist/src/main/k8s/ozone/s3g-statefulset.yaml
  15. 29 0
      hadoop-ozone/dist/src/main/k8s/ozone/scm-public-service.yaml
  16. 29 0
      hadoop-ozone/dist/src/main/k8s/ozone/scm-service.yaml
  17. 67 0
      hadoop-ozone/dist/src/main/k8s/ozone/scm-statefulset.yaml
  18. 51 0
      hadoop-ozone/dist/src/main/k8s/prometheus/configmap.yaml
  19. 46 0
      hadoop-ozone/dist/src/main/k8s/prometheus/deployment.yaml
  20. 28 0
      hadoop-ozone/dist/src/main/k8s/prometheus/prometheus-public-serivce.yaml
  21. 31 0
      hadoop-ozone/dist/src/main/k8s/prometheus/role.yaml
  22. 27 0
      hadoop-ozone/dist/src/main/k8s/prometheus/rolebindng.yaml
  23. 29 0
      hadoop-ozone/dist/src/main/k8s/prometheus/scm-public-service.yaml
  24. 19 0
      hadoop-ozone/dist/src/main/k8s/prometheus/service-account.yaml
  25. 25 0
      hadoop-ozone/dist/src/main/k8s/prometheus/service.yaml

+ 21 - 0
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

+ 85 - 0
hadoop-ozone/dist/README.md

@@ -0,0 +1,85 @@
+<!---
+  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
+
+  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. See accompanying LICENSE file.
+-->
+
+# 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

+ 7 - 0
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

+ 25 - 0
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/*

+ 34 - 0
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"

+ 29 - 0
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

+ 29 - 0
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

+ 52 - 0
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

+ 29 - 0
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

+ 29 - 0
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

+ 72 - 0
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: {}

+ 29 - 0
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

+ 29 - 0
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

+ 49 - 0
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: {}

+ 29 - 0
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

+ 29 - 0
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

+ 67 - 0
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: {}

+ 51 - 0
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

+ 46 - 0
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

+ 28 - 0
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

+ 31 - 0
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"]

+ 27 - 0
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

+ 29 - 0
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

+ 19 - 0
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

+ 25 - 0
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