Skip to content

Commit

Permalink
Replace use of PetSet with StatefulSet for Kubernetes 1.5+
Browse files Browse the repository at this point in the history
  • Loading branch information
David Rauschenbach committed Jan 25, 2017
1 parent 8e22430 commit b75a71c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 34 deletions.
28 changes: 14 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ MANIFESTS=./manifests
NAMESPACE_FILES_BASE=yarn-cluster-namespace.yaml
NAMESPACE_FILES=$(addprefix $(MANIFESTS)/,yarn-cluster-namespace.yaml)

HDFS_FILES_BASE=hdfs-nn-petset.yaml hdfs-dn-petset.yaml
HDFS_FILES_BASE=hdfs-nn-statefulset.yaml hdfs-dn-statefulset.yaml
HDFS_FILES=$(addprefix $(MANIFESTS)/,$(HDFS_FILES_BASE))

YARN_FILES_BASE=yarn-rm-petset.yaml yarn-nm-petset.yaml
YARN_FILES_BASE=yarn-rm-statefulset.yaml yarn-nm-statefulset.yaml
YARN_FILES=$(addprefix $(MANIFESTS)/,$(YARN_FILES_BASE))

ZEPPELIN_FILES_BASE=zeppelin-petset.yaml
ZEPPELIN_FILES_BASE=zeppelin-statefulset.yaml
ZEPPELIN_FILES=$(addprefix $(MANIFESTS)/,$(ZEPPELIN_FILES_BASE))

all: init create-apps
Expand Down Expand Up @@ -55,7 +55,7 @@ $(MANIFESTS)/%.yaml.delete: kubectl
delete-pod-%: kubectl
$(KUBECTL) delete pod $*

delete-petset-pods-%: kubectl
delete-statefulset-pods-%: kubectl
-@for pod in `$(KUBECTL) get pods -l component=$* -o json | jq -r '.items[].metadata.name'`; do make delete-pod-$$pod; done

### Namespace
Expand Down Expand Up @@ -91,30 +91,30 @@ delete-apps: delete-zeppelin delete-yarn delete-hdfs

### HDFS
create-hdfs: $(HDFS_FILES)
delete-hdfs: $(addsuffix .delete,$(HDFS_FILES)) delete-petset-pods-hdfs-dn delete-petset-pods-hdfs-nn
delete-hdfs: $(addsuffix .delete,$(HDFS_FILES)) delete-statefulset-pods-hdfs-dn delete-statefulset-pods-hdfs-nn
scale-dn: kubectl
@CURR=`$(KUBECTL) get petset hdfs-dn -o json | jq -r '.status.replicas'` ; \
@CURR=`$(KUBECTL) get statefulset hdfs-dn -o json | jq -r '.status.replicas'` ; \
IN="" && until [ -n "$$IN" ]; do read -p "Enter number of HDFS Data Node replicas (current: $$CURR): " IN; done ; \
$(KUBECTL) patch petset hdfs-dn -p '{"spec":{"replicas": '$$IN'}}'
$(KUBECTL) patch statefulset hdfs-dn -p '{"spec":{"replicas": '$$IN'}}'

### YARN
create-yarn: $(YARN_FILES)
delete-yarn: delete-yarn-rm-pf $(addsuffix .delete,$(YARN_FILES)) delete-petset-pods-yarn-nm delete-petset-pods-yarn-rm
delete-yarn: delete-yarn-rm-pf $(addsuffix .delete,$(YARN_FILES)) delete-statefulset-pods-yarn-nm delete-statefulset-pods-yarn-rm
scale-nm: kubectl
@CURR=`$(KUBECTL) get petset yarn-nm -o json | jq -r '.status.replicas'` ; \
@CURR=`$(KUBECTL) get statefulset yarn-nm -o json | jq -r '.status.replicas'` ; \
IN="" && until [ -n "$$IN" ]; do read -p "Enter number of YARN Node Manager replicas (current: $$CURR): " IN; done ; \
$(KUBECTL) patch petset yarn-nm -p '{"spec":{"replicas": '$$IN'}}'
$(KUBECTL) patch statefulset yarn-nm -p '{"spec":{"replicas": '$$IN'}}'

### Zeppelin
create-zeppelin: $(ZEPPELIN_FILES)
delete-zeppelin: delete-zeppelin-pf $(addsuffix .delete,$(ZEPPELIN_FILES)) delete-petset-pods-zeppelin
delete-zeppelin: delete-zeppelin-pf $(addsuffix .delete,$(ZEPPELIN_FILES)) delete-statefulset-pods-zeppelin

### Helper targets
get-ns: kubectl
$(KUBECTL) get ns

get-petsets: kubectl
$(KUBECTL) get petsets
get-statefulsets: kubectl
$(KUBECTL) get statefulsets

get-pods: kubectl
$(KUBECTL) get pods
Expand Down Expand Up @@ -153,7 +153,7 @@ delete-%-pf: kubectl

delete-pf: kubectl delete-zeppelin-pf delete-yarn-rm-pf

HADOOP_VERSION=$(shell grep "image: " manifests/yarn-rm-petset.yaml|cut -d'/' -f2|cut -d ':' -f2)
HADOOP_VERSION=$(shell grep "image: " manifests/yarn-rm-statefulset.yaml|cut -d'/' -f2|cut -d ':' -f2)
test: wait-for-pod-yarn-nm-0
$(KUBECTL) exec -it yarn-nm-0 -- /usr/local/hadoop/bin/hadoop jar /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-$(HADOOP_VERSION)-tests.jar TestDFSIO -write -nrFiles 5 -fileSize 128MB -resFile /tmp/TestDFSIOwrite.txt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ spec:
selector:
component: hdfs-dn
---
apiVersion: apps/v1alpha1
kind: PetSet
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: hdfs-dn
spec:
Expand All @@ -27,8 +27,6 @@ spec:
metadata:
labels:
component: hdfs-dn
annotations:
pod.alpha.kubernetes.io/initialized: "true"
spec:
terminationGracePeriodSeconds: 0
containers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ spec:
selector:
component: hdfs-nn
---
apiVersion: apps/v1alpha1
kind: PetSet
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: hdfs-nn
spec:
Expand All @@ -27,8 +27,6 @@ spec:
metadata:
labels:
component: hdfs-nn
annotations:
pod.alpha.kubernetes.io/initialized: "true"
spec:
terminationGracePeriodSeconds: 0
containers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ spec:
selector:
component: yarn-nm
---
apiVersion: apps/v1alpha1
kind: PetSet
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: yarn-nm
spec:
Expand All @@ -28,8 +28,6 @@ spec:
metadata:
labels:
component: yarn-nm
annotations:
pod.alpha.kubernetes.io/initialized: "true"
spec:
terminationGracePeriodSeconds: 0
containers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ spec:
selector:
component: yarn-rm
---
apiVersion: apps/v1alpha1
kind: PetSet
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: yarn-rm
spec:
Expand All @@ -41,8 +41,6 @@ spec:
metadata:
labels:
component: yarn-rm
annotations:
pod.alpha.kubernetes.io/initialized: "true"
spec:
terminationGracePeriodSeconds: 0
containers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ spec:
selector:
component: zeppelin
---
apiVersion: apps/v1alpha1
kind: PetSet
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: zeppelin
spec:
Expand All @@ -26,8 +26,6 @@ spec:
metadata:
labels:
component: zeppelin
annotations:
pod.alpha.kubernetes.io/initialized: "true"
spec:
terminationGracePeriodSeconds: 0
containers:
Expand Down

0 comments on commit b75a71c

Please sign in to comment.