Skip to content

Commit

Permalink
Use gluster volume for the containers
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinmay Naik authored and mattkanwisher committed Feb 10, 2018
1 parent 5b9257a commit 7eb0743
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 37 deletions.
8 changes: 5 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import (
)

const (
DefaultKey = "CONFIG"
DefaultKey = "CONFIG"
DefaultGanacheImage = "gcr.io/robotic-catwalk-188706/loom-ganache:test"
DefaultGatewayImage = "gcr.io/robotic-catwalk-188706/rpc_gateway:e3face0"
)

type S3EndPoint struct {
Expand Down Expand Up @@ -65,8 +67,8 @@ var (
level = envflag.String("LOG_LEVEL", "debug", "Log level minimum to output. Info/Debug/Warn")
serverHost = envflag.String("SERVER_HOST", "http://127.0.0.1:8081", "hostname for oauth redirects")
loomDashboardHost = envflag.String("LOOM_DASHBOARD_API_HOST", "https://dashboard.loomx.io", "hostname for production dashboard to read data from it, for the gateway.")
gatewayDockerImage = envflag.String("GATEWAY_DOCKER_IMAGE", "gcr.io/robotic-catwalk-188706/rpc_gateway:e3face0", "Gateway docker image version")
ganacheDockerImage = envflag.String("GANACHE_DOCKER_IMAGE", "gcr.io/robotic-catwalk-188706/loom-ganache:5a4cfce", "Ganache docker image version")
gatewayDockerImage = envflag.String("GATEWAY_DOCKER_IMAGE", DefaultGatewayImage, "Gateway docker image version")
ganacheDockerImage = envflag.String("GANACHE_DOCKER_IMAGE", DefaultGanacheImage, "Ganache docker image version")
ethereumURI = envflag.String("ETHEREUM_URI", "http://localhost:8545", "Test RPC Host address")
kubeConfigPath = envflag.String("KUBECONFIFG", "~/.kube/config", "Path to K8s configuration file")
)
Expand Down
10 changes: 5 additions & 5 deletions controllers/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ func deployToK8s(filename, slug string, cfg *config.Config) error {
}

env := map[string]interface{}{
"APP_ZIP_FILE": fmt.Sprintf("do://uploads/%s", filename),
"DEMO_MODE": "false",
"APP_SLUG": slug,
"ETHEREUM_URI": fmt.Sprintf("http://ganache-%v:8545", slug),
"PROXY_ADDR": fmt.Sprintf("http://ganache-%v:8545", slug),
"APP_ZIP_FILE": fmt.Sprintf("do://uploads/%s", filename),
"DEMO_MODE": "false",
"APP_SLUG": slug,
"ETHEREUM_URI": fmt.Sprintf("http://ganache-%v:8545", slug),
"PROXY_ADDR": fmt.Sprintf("http://ganache-%v:8545", slug),
}

if err := k8s.Install(gateway.Ident, slug, env, cfg); err != nil {
Expand Down
5 changes: 0 additions & 5 deletions jenkins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,3 @@ export IMAGE=dashboard
#sed -i 's/REV_REPLACE/'"$REV"'/g' $TMP_FILE
#cat $TMP_FILE
#NOMAD_ADDR=http://45.55.246.200:4646 nomad run $TMP_FILE


echo "Ok now building the RPC Gateway, we don't deploy it anyway automatically yet"
#todo maybe have two jenkins jobs??
./build_proxy_docker.sh
17 changes: 10 additions & 7 deletions k8s/ganache/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ import (

// How many pods should be created for this service.
const (
ganacheReplicas = 1
ganachePort = 8545
ganacheMemLimit = "200M"
ganacheCPULimit = "200m"
ganacheReplicas = 1
ganachePort = 8545
ganacheMemLimit = "200M"
ganacheCPULimit = "200m"
GlusterEndpoint = "staging-glusterfs"
GlusterVolumeName = "ganache-data"
)

func (g *Installer) createDeploymentStruct(image, slug string, env []apiv1.EnvVar, client *kubernetes.Clientset) (*v1beta1.Deployment, error) {
Expand Down Expand Up @@ -62,9 +64,10 @@ func (g *Installer) createDeploymentStruct(image, slug string, env []apiv1.EnvVa
Volumes: []apiv1.Volume{
{
Name: "ganachedb",
VolumeSource: apiv1.VolumeSource{GCEPersistentDisk: &apiv1.GCEPersistentDiskVolumeSource{
PDName: "ganache-disk",
FSType: "ext4",
VolumeSource: apiv1.VolumeSource{Glusterfs: &apiv1.GlusterfsVolumeSource{
EndpointsName: GlusterEndpoint,
Path: GlusterVolumeName,
ReadOnly: false,
}},
},
},
Expand Down
22 changes: 5 additions & 17 deletions k8s/installer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,22 @@ var kubeConfigPath string
var gwi gateway.Installer

const (
slug = "hello-world"
gatewayDockerVersion = "gcr.io/robotic-catwalk-188706/rpc_gateway:e3face0"
ganacheDockerVersion = "gcr.io/robotic-catwalk-188706/loom-ganache:5a4cfce"
slug = "hello-world"
)

func TestGetZone(t *testing.T) {
c := &config.Config{KubeConfigPath: kubeConfigPath}

client, _ := makeClient(c)
slug1, err := gwi.GetZone("hello-world", client)
if err != nil {
if _, err := gwi.GetZone(slug, client); err != nil {
t.Error(err)
return
}

if slug1 != "us-central1-c" {
t.Error("For default test config, the value should be us-central1-c")
}

slug2, err := gwi.GetZone("abcd", client)
if err != nil {
if _, err := gwi.GetZone("abcd", client); err != nil {
t.Error(err)
return
}

if slug2 != "us-central1-f" {
t.Error("For default test config, the value should be us-central1-f")
}
}

func TestInstallAndUpdate(t *testing.T) {
Expand All @@ -69,8 +57,8 @@ func TestInstallAndUpdate(t *testing.T) {
})

// Set the Image Path.
c.GatewayDockerImage = gatewayDockerVersion
c.GanacheDockerImage = ganacheDockerVersion
c.GatewayDockerImage = config.DefaultGatewayImage
c.GanacheDockerImage = config.DefaultGanacheImage

t.Run("Install a ganache service for this service", func(t *testing.T) {
if err := Install(ganache.Ident, slug, map[string]interface{}{}, c); err != nil {
Expand Down

0 comments on commit 7eb0743

Please sign in to comment.