Skip to content

Commit

Permalink
[added] kubernetes support
Browse files Browse the repository at this point in the history
Change-Id: Ibc64e9a8915d71ac588b04e7b39b6227e5c4d510
  • Loading branch information
akimaki23 committed Sep 7, 2017
1 parent 2d833de commit 5815f8f
Show file tree
Hide file tree
Showing 12 changed files with 324 additions and 0 deletions.
72 changes: 72 additions & 0 deletions MMOCoreORB/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,75 @@ deleteidl:
$(IDLC) -delete $(IDL_DIRECTIVES) -sd src anyadEclipse
#done

DB_NAMESPACE=
DB_IMAGE=

APP_NAMESPACE=swgemu
APP_NAME=core3
APP_IMAGE=akimaki/swgemu-core3:1.0

build-docker:
sudo docker build -t ${APP_IMAGE} docker
sudo docker push ${APP_IMAGE}
sudo docker images | grep "<none>" | awk '{print $$3}' | xargs sudo docker rmi
#done

init-storage:
kubectl create -f helm/storage-class.yaml --validate=false
#done

init-db-helm:
kubectl create namespace ${DB_NAMESPACE}
kubectl create serviceaccount --namespace ${DB_NAMESPACE} tiller
kubectl create clusterrolebinding tiller-cluster-rule-${DB_NAMESPACE} --clusterrole=cluster-admin --serviceaccount=${DB_NAMESPACE}:tiller
helm init --service-account=tiller --tiller-namespace=nuodb
#done

deploy-db-helm:
helm install helm/${DB_NAMESPACE} --tiller-namespace ${DB_NAMESPACE} --name ${DB_NAMESPACE} --namespace ${DB_NAMESPACE}
#done

shutdown-db-helm:
helm delete ${DB_NAMESPACE} --tiller-namespace ${DB_NAMESPACE} --purge
#done

init-app-helm:
kubectl create namespace $(APP_NAMESPACE)
kubectl create serviceaccount --namespace $(APP_NAMESPACE) tiller
kubectl create clusterrolebinding tiller-cluster-rule-$(APP_NAMESPACE) --clusterrole=cluster-admin --serviceaccount=$(APP_NAMESPACE):tiller
helm init --service-account=tiller --tiller-namespace=$(APP_NAMESPACE)
#done

deploy-app-helm:
helm install helm/${APP_NAME} --tiller-namespace $(APP_NAMESPACE) --name $(APP_NAME) --namespace $(APP_NAMESPACE)
#done

shutdown-app-helm:
helm delete $(APP_NAME) --tiller-namespace $(APP_NAMESPACE) --purge
#done

purge-app-helm:
kubectl delete clusterrolebinding tiller-cluster-rule-$(APP_NAMESPACE)
kubectl delete serviceaccount --namespace $(APP_NAMESPACE) tiller
kubectl delete namespace $(APP_NAMESPACE)
#done

status-db-helm:
helm ls --all --tiller-namespace ${DB_NAMESPACE}
kubectl get svc --namespace ${DB_NAMESPACE}
kubectl get po --namespace ${DB_NAMESPACE}
kubectl exec nuodb-sm-0 --namespace nuodb -- /opt/nuodb/bin/nuodbmgr --broker localhost --password bird --command "show domain summary"
#done

status-app-helm:
helm ls --all --tiller-namespace $(APP_NAMESPACE)
kubectl get svc --namespace $(APP_NAMESPACE)
kubectl get po --namespace $(APP_NAMESPACE)
#done

exec-app:
kubectl exec core3-zone-0 -n swgemu -ti -- bash

pv-nuodb:
kubectl get pv | grep nuodb/nuodb-var-nuodb-sm | awk '{print $$1}' | xargs -I ID kubectl describe pv ID | grep "Path:" | awk '{ print $$2 }'
#done
40 changes: 40 additions & 0 deletions MMOCoreORB/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM debian:jessie

RUN echo 'APT::Install-Recommends "0";\nAPT::Install-Suggests "0";' > /etc/apt/apt.conf.d/01norecommends

RUN apt-get update && apt-get upgrade -y

RUN echo "mysql-server mysql-server/root_password password root" | debconf-set-selections
RUN echo "mysql-server mysql-server/root_password_again password root" | debconf-set-selections

RUN apt-get install -y gcc g++ make autoconf automake autotools-dev git libc6-dev libdb5.3-dev libreadline-dev libmysqlclient-dev libssl-dev git vim openjdk-7-jre-headless gdb gccxml mysql-server

#RUN find /var/lib/mysql -type f -exec touch {} \; && service mysql start

#RUN echo 'CREATE DATABASE swgemu;' | mysql -uroot -proot
#RUN echo 'GRANT ALL ON *.* TO `swgemu`@`localhost` IDENTIFIED BY "123456";' | mysql -uroot -proot

RUN mkdir -p /swgemu/MMOEngine && mkdir -p /swgemu/MMOCoreORB
#RUN ln -s /swgemu/MMOEngine/bin/idlc /usr/local/bin/idlc

RUN apt-get install -y wget && wget http://www.lua.org/ftp/lua-5.3.3.tar.gz && tar -xvf lua-5.3.3.tar.gz && cd lua-5.3.3 && make linux install && cd .. && rm -R lua-5.3.3 && rm lua-5.3.3.tar.gz && ldconfig

RUN mkdir -p /home/swgemu/workspace/tre

#RUN apt-get install -y clang-3.5

RUN mkdir git && cd git && git clone http://review.swgemu.com/p/Core3.git && git clone http://review.swgemu.com/p/PublicEngine.git && cd PublicEngine/MMOEngine && make && chmod +x bin/idlc && cp bin/idlc /usr/local/bin/idlc && cd ../../Core3 && git checkout unstable && ln -s ../PublicEngine/MMOEngine MMOEngine

ENV CLASSPATH="/git/PublicEngine/MMOEngine/bin/idlc.jar"
RUN echo 'export CLASSPATH="/git/PublicEngine/MMOEngine/bin/idlc.jar"' >> /root/.profile

RUN cd git/Core3/MMOCoreORB && make config && make build

RUN apt-get install -y supervisor

# copy the supervisor conf file into the image
ADD scripts/supervisord-core3.conf /etc/supervisor/conf.d/supervisord-core3.conf

ADD scripts/run.sh /tmp/
RUN /bin/chmod +x /tmp/run.sh
CMD /tmp/run.sh
6 changes: 6 additions & 0 deletions MMOCoreORB/docker/scripts/supervisord-core3.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[supervisord]
nodaemon=true

[program:core3]
user=root
command=/git/Core3/MMOCoreORB/bin/core3
5 changes: 5 additions & 0 deletions MMOCoreORB/helm/core3/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
.git
9 changes: 9 additions & 0 deletions MMOCoreORB/helm/core3/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
description: An SwgEmu cluster
keywords:
- swgemu
- core3
maintainers:
- email: oru@swgemu.com
name: oru
name: core3
version: "1.0"
33 changes: 33 additions & 0 deletions MMOCoreORB/helm/core3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# nginx: An advanced example chart

This Helm chart provides examples of some of Helm's more powerful
features.

**This is not a production-grade chart. It is an example.**

The chart installs a simple nginx server according to the following
pattern:

- A `ConfigMap` is used to store the files the server will serve.
([templates/configmap.yaml](templates/configmap.yaml))
- A `Deployment` is used to create a Replica Set of nginx pods.
([templates/deployment.yaml](templates/deployment.yaml))
- A `Service` is used to create a gateway to the pods running in the
replica set ([templates/svc.yaml](templates/svc.yaml))

The [values.yaml](values.yaml) exposes a few of the configuration options in the
charts, though there are some that are not exposed there (like
`.image`).

The [templates/_helpers.tpl](templates/_helpers.tpl) file contains helper templates. The leading
underscore (`_`) on the filename is semantic. It tells the template renderer
that this file does not contain a manifest. That file declares some
templates that are used elsewhere in the chart.

Helpers (usually called "partials" in template languages) are an
advanced way for developers to structure their templates for optimal
reuse.

You can deploy this chart with `helm install docs/examples/nginx`. Or
you can see how this chart would render with `helm install --dry-run
--debug docs/examples/nginx`.
16 changes: 16 additions & 0 deletions MMOCoreORB/helm/core3/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{define "name"}}{{default "core3" .Values.nameOverride | trunc 63 | trimSuffix "-" }}{{end}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this
(by the DNS naming spec).
*/}}
{{define "fullname"}}
{{- $name := default "core3" .Values.nameOverride -}}
{{printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{end}}
23 changes: 23 additions & 0 deletions MMOCoreORB/helm/core3/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# A headless service to create DNS records
apiVersion: v1
kind: Service
metadata:
name: {{template "name" .}}
labels:
app: {{template "name" .}}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
chart: "{{.Chart.Name}}-{{.Chart.Version}}"
spec:
ports:
- port: {{default 44421 .Values.zonePort}}
name: core3-zone
protocol: UDP
- port: {{default 44422 .Values.pingPort}}
name: core3-ping
protocol: UDP
# - port: {{default 44455 .Values.statusPort}}
# name: core3-status
type: LoadBalancer
selector:
app: {{template "name" .}}
91 changes: 91 additions & 0 deletions MMOCoreORB/helm/core3/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: {{template "name" .}}-zone
labels:
# The "heritage" label is used to track which tool deployed a given chart.
# It is useful for admins who want to see what releases a particular tool
# is responsible for.
heritage: {{ .Release.Service | quote }}
# This makes it easy to search for all components of a release using kubectl.
release: {{ .Release.Name | quote }}
# This makes it easy to audit chart usage.
chart: "{{.Chart.Name}}-{{.Chart.Version}}"
spec:
serviceName: "{{template "name" .}}"
replicas: {{default 1 .Values.replicas}}
template:
metadata:
labels:
app: {{template "name" .}}
annotations:
pod.alpha.kubernetes.io/initialized: "true"
spec:
terminationGracePeriodSeconds: 0
containers:
- name: {{template "name" .}}
image: {{default "akimaki/swgemu-core3" .Values.image}}:{{default "1.0" .Chart.Version}}
ports:
- containerPort: {{default 44421 .Values.zonePort}}
name: core3-zone
protocol: UDP
- containerPort: {{default 44422 .Values.pingPort}}
name: core3-ping
protocol: UDP
# - containerPort: {{default 44455 .Values.statusPort}}
# name: core3-status
env:
- name: MYSQL_HOST
valueFrom:
secretKeyRef:
name: mysql-secret
key: host
- name: MYSQL_PORT
valueFrom:
secretKeyRef:
name: mysql-secret
key: port
- name: MYSQL_NAME
valueFrom:
secretKeyRef:
name: mysql-secret
key: name
- name: MYSQL_USER
valueFrom:
secretKeyRef:
name: mysql-secret
key: user
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-secret
key: password
- name: MYSQL_SECRET
valueFrom:
secretKeyRef:
name: mysql-secret
key: secret
volumeMounts:
- name: bdb-database
mountPath: /git/Core3/MMOCoreORB/bin/databases
- name: mysql-varlib
mountPath: /var/lib/mysql
volumeClaimTemplates:
- metadata:
name: bdb-database
annotations:
volume.beta.kubernetes.io/storage-class: local-storage
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 50Gi
- metadata:
name: mysql-varlib
annotations:
volume.beta.kubernetes.io/storage-class: local-storage
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
6 changes: 6 additions & 0 deletions MMOCoreORB/helm/core3/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Default values for nginx.
# This is a YAML-formatted file.
# Declare name/value pairs to be passed into your templates.

# Number of nginx instances to run
replicaCount: 1
13 changes: 13 additions & 0 deletions MMOCoreORB/helm/mysql-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Secret
metadata:
name: mysql-secret
namespace: swgemu
data:
host: host # in base64
port: port # in base64
name: name # in base64
user: user # in base64
password: password # in base64
secret: secret # in base64

10 changes: 10 additions & 0 deletions MMOCoreORB/helm/storage-class.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
kind: StorageClass
apiVersion: storage.k8s.io/v1beta1
metadata:
namespace: kube-system
name: local-storage
annotations:
storageclass.beta.kubernetes.io/is-default-class: "false"
labels:
kubernetes.io/cluster-service: "true"
provisioner: kubernetes.io/host-path

0 comments on commit 5815f8f

Please sign in to comment.