Skip to content

Commit

Permalink
provider: initial kube workload execution
Browse files Browse the repository at this point in the history
 * provider: run workloads in kubernetes
 * sdl: add `accept`, list of hosts to accept requests for.
 * sdl: populate service args, env.
 * types/provider: fix yaml parsing.
 * _run/kube: single-node workload demo.
  • Loading branch information
boz committed May 31, 2018
1 parent 94bce58 commit 9c4bd22
Show file tree
Hide file tree
Showing 29 changed files with 1,138 additions and 151 deletions.
2 changes: 2 additions & 0 deletions _docs/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ services:
expose:
- port: 443
as: 8080
accept:
- foo.com
to:
- global: true

Expand Down
4 changes: 3 additions & 1 deletion _docs/sdl.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ The top-level `services` entry contains a map of workloads to be ran on the Akas

| Name | Required | Meaning |
|--- | --- | --- |
| `port` | Yes | Port to expose |
| `port` | Yes | Container port to expose |
| `as` | No | Port number to expose the container port as |
| `accept` | No | List of hosts to accept connections for |
| `proto` | No | Protocol type (`tcp`,`http`, or `https`) |
| `to` | No | List of entities allowed to connect. See [services.expose.to](#servicesexposeto) |

Expand Down
2 changes: 2 additions & 0 deletions _run/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ AKASHD := $(AKASHD)/akashd
DATA_ROOT = data
NODE_ROOT = $(DATA_ROOT)/node

all:
(cd $(AKASH_ROOT) && make all)
build:
(cd $(AKASH_ROOT) && make build)
akash:
Expand Down
1 change: 1 addition & 0 deletions _run/kube/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/data
2 changes: 2 additions & 0 deletions _run/kube/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../common.mk

75 changes: 75 additions & 0 deletions _run/kube/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Akash: Single-Node Local Setup with Minikube

Run a network with a single, local node and execute workloads in Minikube.

Running through the entire suite requires four terminals.
Each command is marked __t1__-__t4__ to indicate a suggested terminal number.

## Setup

__t1__: Start and initialize minikube
```sh
$ minikube start
$ kubectl create -f contour.yml
```

__t1__: Build binaries
```sh
$ make
```

__t1__: Initialize environment
```sh
$ ./run.sh init
```

## Start Network

__t2__: Run `akashd`
```sh
$ ./run.sh akashd
```

## Transfer Tokens

__t1__: Query _master_ account
```sh
$ ./run.sh query master
```

__t1__: Send tokens to _other_ account
```sh
$ ./run.sh send
```

__t1__: Query _master_ account
```sh
$ ./run.sh query master
```

__t1__: Query _other_ account
```sh
$ ./run.sh query other
```

## Marketplace

__t3__: Start marketplace monitor
```sh
$ ./run.sh marketplace
```

__t4__: Run provider
```sh
$ ./run.sh provider
```

__t1__: Create Deployment
```sh
$ ./run.sh deploy
```

__t1__: Ping workload
```sh
$ ./run.sh ping
```
170 changes: 170 additions & 0 deletions _run/kube/contour.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# This file is generated from the individual yaml files by deployment/render.sh.
# Do not edit this file directly but instead edit the source files and
# re-render.
apiVersion: v1
kind: Namespace
metadata:
name: heptio-contour
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: contour
namespace: heptio-contour
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: ingressroutes.contour.heptio.com
labels:
component: ingressroute
spec:
group: contour.heptio.com
version: v1beta1
scope: Namespaced
names:
plural: ingressroutes
kind: IngressRoute
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
labels:
app: contour
name: contour
namespace: heptio-contour
spec:
selector:
matchLabels:
app: contour
updateStrategy:
type: RollingUpdate
template:
metadata:
labels:
app: contour
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9001"
prometheus.io/path: "/stats"
prometheus.io/format: "prometheus"
spec:
containers:
- image: docker.io/envoyproxy/envoy-alpine:v1.6.0
name: envoy
ports:
- containerPort: 8080
name: http
- containerPort: 8443
name: https
command: ["envoy"]
args: ["-c", "/config/contour.yaml", "--service-cluster", "cluster0", "--service-node", "node0", "-l", "info", "--v2-config-only"]
volumeMounts:
- name: contour-config
mountPath: /config
- image: gcr.io/heptio-images/contour:master
imagePullPolicy: Always
name: contour
command: ["contour"]
args: ["serve", "--incluster"]
initContainers:
- image: gcr.io/heptio-images/contour:master
imagePullPolicy: Always
name: envoy-initconfig
command: ["contour"]
args: ["bootstrap", "/config/contour.yaml"]
volumeMounts:
- name: contour-config
mountPath: /config
volumes:
- name: contour-config
emptyDir: {}
dnsPolicy: ClusterFirst
serviceAccountName: contour
terminationGracePeriodSeconds: 30
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: contour
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: contour
subjects:
- kind: ServiceAccount
name: contour
namespace: heptio-contour
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: contour
rules:
- apiGroups:
- ""
resources:
- configmaps
- endpoints
- nodes
- pods
- secrets
verbs:
- list
- watch
- apiGroups:
- ""
resources:
- nodes
verbs:
- get
- apiGroups:
- ""
resources:
- services
verbs:
- get
- list
- watch
- apiGroups:
- extensions
resources:
- ingresses
verbs:
- get
- list
- watch
- apiGroups: ["contour.heptio.com"]
resources: ["ingressroutes"]
verbs:
- get
- list
- watch
---
apiVersion: v1
kind: Service
metadata:
name: contour
namespace: heptio-contour
annotations:
# This annotation puts the AWS ELB into "TCP" mode so that it does not
# do HTTP negotiation for HTTPS connections at the ELB edge.
# The downside of this is the remote IP address of all connections will
# appear to be the internal address of the ELB. See docs/proxy-proto.md
# for information about enabling the PROXY protocol on the ELB to recover
# the original remote IP address.
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: tcp
spec:
ports:
- port: 80
name: http
protocol: TCP
targetPort: 8080
- port: 443
name: https
protocol: TCP
targetPort: 8443
selector:
app: contour
type: NodePort
---
30 changes: 30 additions & 0 deletions _run/kube/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
services:
web:
image: gcr.io/google_containers/echoserver:1.8
expose:
- port: 8080
as: 80
accept:
- web.192.168.99.101.nip.io
to:
- global: true

profiles:
compute:
web:
cpu: 2
memory: 3
disk: 5
placement:
westcoast:
attributes:
region: us-west
pricing:
web: 8

deployment:
web:
westcoast:
profile: web
count: 5
41 changes: 41 additions & 0 deletions _run/kube/echo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
apiVersion: v1
kind: Pod
metadata:
name: echo
labels:
app: echo
spec:
containers:
- image: gcr.io/google_containers/echoserver:1.8
name: envoy
ports:
- containerPort: 8080
name: http
---
apiVersion: v1
kind: Service
metadata:
name: echo
labels:
app: echo
spec:
selector:
app: echo
ports:
- port: 80
targetPort: 8080
name: http
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: echo
labels:
app: echo
spec:
backend:
serviceName: echo
servicePort: 80
rules:
- host: echo.192.168.99.101.nip.io
16 changes: 16 additions & 0 deletions _run/kube/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
source ../common.sh

PROVIDER_DIR=$DATA_ROOT/provider

akash() {
_akash "$@"
}

akashd() {
_akashd "$@"
}

akash_provider() {
"$AKASH_ROOT/akash" -d "$PROVIDER_DIR" "$@"
}

6 changes: 6 additions & 0 deletions _run/kube/provider.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
hostURI: http://localhost:3001/manifest
attributes:
- name: region
value: us-west
- name: tier
value: "5"
Loading

0 comments on commit 9c4bd22

Please sign in to comment.