Skip to content

Commit

Permalink
Update kubernetes deployment apis k8s post 1.9 (apache#4700)
Browse files Browse the repository at this point in the history
**Motivation**

Fixes apache#4698 and apache#4699 

**List of changes**

1. Two new folders under pulsar/deployment/kubernetes/generic : 
- original : contains the original scripts (pre Kubernetes 1.9)
- k8s-1-9-and-above : contains the new scripts with APIs ipdated (Kubernetes 1.9 and above)

2. bookie.yaml :
- Migrate DaemonSet api version from extensions/v1beta1 to apps/v1
- Declare the bookie service before the DaemonSet object for bookies

3. broker.yaml
- Migrate Deployment api version from apps/v1beta1 to apps/v1
- Declare the bookie service before the Deployment object for brokers

4. monitoring.yaml :
- Migrate all Deployment api version from apps/v1beta1 to apps/v1
- Declare each service before the Deployment object the service is bound to

5. zookeeper.yaml :
- Migrate StatefulSet api version from apps/v1beta1 to apps/v1
- Declare the service before the StatefulSet object for zookeeper

6. proxy.yaml
- Migrate Deployment api version from apps/v1beta1 to apps/v1
- Declare the bookie service before the Deployment object for proxy.
  • Loading branch information
Guillaume Braibant authored and sijie committed Aug 5, 2019
1 parent 822531c commit bb1108e
Show file tree
Hide file tree
Showing 14 changed files with 740 additions and 0 deletions.
File renamed without changes.
129 changes: 129 additions & 0 deletions deployment/kubernetes/generic/k8s-1-9-and-above/bookie.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
#
# 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: bookie-config
data:
PULSAR_MEM: "\" -Xms64m -Xmx256m -XX:MaxDirectMemorySize=256m\""
dbStorage_writeCacheMaxSizeMb: "32" # Write cache size (direct memory)
dbStorage_readAheadCacheMaxSizeMb: "32" # Read cache size (direct memory)
zkServers: zookeeper
statsProviderClass: org.apache.bookkeeper.stats.prometheus.PrometheusMetricsProvider
---
##
## Define the Bookie headless service
## In practice, in this case, it is only useful to have a view of
## all the bookie pods that are present
##
apiVersion: v1
kind: Service
metadata:
name: bookkeeper
labels:
app: pulsar
component: bookkeeper
spec:
ports:
- port: 3181
name: server
clusterIP: None
selector:
app: pulsar
component: bookkeeper
---
## BookKeeper servers need to access the local disks and the pods
## cannot be moved across different nodes.
## For this reason, we run BK as a daemon set, one for each node in the
## cluster, unless restricted by label selectors
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: bookie
labels:
app: pulsar
component: bookkeeper
spec:
template:
metadata:
labels:
app: pulsar
component: bookkeeper
# Specify cluster to allow aggregation by cluster in
# the metrics
cluster: local
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "8000"

spec:
containers:
- name: bookie
image: apachepulsar/pulsar-all:latest
command: ["sh", "-c"]
args:
- >
bin/apply-config-from-env.py conf/bookkeeper.conf &&
bin/apply-config-from-env.py conf/pulsar_env.sh &&
bin/pulsar bookie
ports:
- containerPort: 3181
hostPort: 3181
name: client
envFrom:
- configMapRef:
name: bookie-config
env:
- name: advertisedAddress
valueFrom:
fieldRef:
fieldPath: status.hostIP

volumeMounts:
- name: journal-disk
mountPath: /pulsar/data/bookkeeper/journal
- name: ledgers-disk
mountPath: /pulsar/data/bookkeeper/ledgers

# bin/bookkeeper shell bookiesanity

initContainers:
# The first time, initialize BK metadata in zookeeper
# Otherwise ignore error if it's already there
- name: bookie-metaformat
image: apachepulsar/pulsar-all:latest
command: ["sh", "-c"]
args:
- >
bin/apply-config-from-env.py conf/bookkeeper.conf &&
bin/bookkeeper shell metaformat --nonInteractive || true;
envFrom:
- configMapRef:
name: bookie-config

volumes:
# Mount local disks
- name: journal-disk
hostPath:
path: /mnt/disks/ssd0
- name: ledgers-disk
hostPath:
path: /mnt/disks/ssd1
103 changes: 103 additions & 0 deletions deployment/kubernetes/generic/k8s-1-9-and-above/broker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#
# 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: broker-config
data:
# Tune for available memory. Increase the heap up to 24G to have
# better GC behavior at high throughput
PULSAR_MEM: "\" -Xms64m -Xmx128m -XX:MaxDirectMemorySize=128m\""
zookeeperServers: zookeeper
configurationStoreServers: zookeeper
clusterName: local
# change the managed ledger settings if you have more bookies
managedLedgerDefaultEnsembleSize: "1"
managedLedgerDefaultWriteQuorum: "1"
managedLedgerDefaultAckQuorum: "1"
# enable pulsar functions
functionsWorkerEnabled: "true"
PF_pulsarFunctionsCluster: local
---
##
## Define the Broker headless service
## In practice, in this case, it is only useful to have a view of
## all the broker pods that are present
##
apiVersion: v1
kind: Service
metadata:
name: broker
labels:
app: pulsar
component: broker
spec:
ports:
- port: 8080
name: http
- port: 6650
name: pulsar
clusterIP: None
selector:
app: pulsar
component: broker
---
##
## Broker deployment definition
##
apiVersion: apps/v1
kind: Deployment
metadata:
name: broker
spec:
replicas: 3
template:
metadata:
labels:
app: pulsar
component: broker
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "8080"
spec:
containers:
- name: broker
image: apachepulsar/pulsar-all:latest
command: ["sh", "-c"]
args:
- >
bin/apply-config-from-env.py conf/broker.conf &&
bin/apply-config-from-env.py conf/pulsar_env.sh &&
bin/gen-yml-from-env.py conf/functions_worker.yml &&
bin/pulsar broker
ports:
- containerPort: 8080
# hostPort: 8080
- containerPort: 6650
# hostPort: 6650
envFrom:
- configMapRef:
name: broker-config
env:
- name: advertisedAddress
valueFrom:
fieldRef:
fieldPath: status.podIP
Loading

0 comments on commit bb1108e

Please sign in to comment.