Skip to content

Commit

Permalink
organize configs
Browse files Browse the repository at this point in the history
Signed-off-by: Plamen Petrov <plamb0brt@gmail.com>
  • Loading branch information
plamenmpetrov committed Nov 30, 2020
1 parent 796b0c4 commit aa6b91a
Show file tree
Hide file tree
Showing 25 changed files with 97 additions and 117 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions configs/knative_workloads/helloworld.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld # The name of the function instance
namespace: default
spec:
template:
spec:
containers:
- image: crccheck/hello-world:latest # Stub image. See https://github.com/ease-lab/vhive/issues/68
ports:
- name: h2c # For GRPC support
containerPort: 50051
env:
- name: GUEST_PORT # Port on which the firecracker-containerd container is accepting requests
value: "50051"
- name: GUEST_IMAGE # Container image to use for firecracker-containerd container
value: "ustiugov/helloworld:var_workload"
19 changes: 19 additions & 0 deletions configs/knative_workloads/helloworldSerial.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworldserial # The name of the function instance
namespace: default
spec:
template:
spec:
containerConcurrency: 1
containers:
- image: crccheck/hello-world:latest # Stub image. See https://github.com/ease-lab/vhive/issues/68
ports:
- name: h2c # For GRPC support
containerPort: 50051
env:
- name: GUEST_PORT # Port on which the firecracker-containerd container is accepting requests
value: "50051"
- name: GUEST_IMAGE # Container image to use for firecracker-containerd container
value: "ustiugov/helloworld:var_workload"
18 changes: 18 additions & 0 deletions configs/knative_workloads/pyaes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: pyaes # The name of the function instance
namespace: default
spec:
template:
spec:
containers:
- image: crccheck/hello-world:latest # Stub image. See https://github.com/ease-lab/vhive/issues/68
ports:
- name: h2c # For GRPC support
containerPort: 50051
env:
- name: GUEST_PORT # Port on which the firecracker-containerd container is accepting requests
value: "50051"
- name: GUEST_IMAGE # Container image to use for firecracker-containerd container
value: "ustiugov/pyaes:var_workload"
18 changes: 18 additions & 0 deletions configs/knative_workloads/rnn_serving.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: rnnserving # The name of the function instance
namespace: default
spec:
template:
spec:
containers:
- image: crccheck/hello-world:latest # Stub image. See https://github.com/ease-lab/vhive/issues/68
ports:
- name: h2c # For GRPC support
containerPort: 50051
env:
- name: GUEST_PORT # Port on which the firecracker-containerd container is accepting requests
value: "50051"
- name: GUEST_IMAGE # Container image to use for firecracker-containerd container
value: "ustiugov/rnn_serving:var_workload"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
50 changes: 15 additions & 35 deletions cri/container_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ func (s *Service) CreateContainer(ctx context.Context, r *criapi.CreateContainer
containerName := config.GetMetadata().GetName()

if containerName == userContainerName {
return s.processUserContainer(ctx, r)
return s.createUserContainer(ctx, r)
}
if containerName == queueProxyName {
return s.processQueueProxy(ctx, r)
return s.createQueueProxy(ctx, r)
}

// Containers irrelevant to user's workload
// Containers relevant for control plane
return s.stockRuntimeClient.CreateContainer(ctx, r)
}

func (s *Service) processUserContainer(ctx context.Context, r *criapi.CreateContainerRequest) (*criapi.CreateContainerResponse, error) {
func (s *Service) createUserContainer(ctx context.Context, r *criapi.CreateContainerRequest) (*criapi.CreateContainerResponse, error) {
var (
stockResp *criapi.CreateContainerResponse
stockErr error
Expand All @@ -73,26 +73,26 @@ func (s *Service) processUserContainer(ctx context.Context, r *criapi.CreateCont
}()

config := r.GetConfig()
guestImage, guestPort, err := getGuestImagePort(config)
guestImage, err := getGuestImage(config)
if err != nil {
log.WithError(err).Error()
return nil, err
}

fi, err := s.coordinator.startVM(context.Background(), guestImage)
funcInst, err := s.coordinator.startVM(context.Background(), guestImage)
if err != nil {
log.WithError(err).Error("failed to start VM")
return nil, err
}

vmConfig := &VMConfig{guestIP: fi.startVMResponse.GuestIP, guestPort: guestPort}
s.insertPodConfig(r.GetPodSandboxId(), vmConfig)
vmConfig := &VMConfig{guestIP: funcInst.startVMResponse.GuestIP, guestPort: guestPortValue}
s.insertPodVMConfig(r.GetPodSandboxId(), vmConfig)

// Wait for placeholder UC to be created
<-stockDone

containerdID := stockResp.ContainerId
err = s.coordinator.insertActive(containerdID, fi)
err = s.coordinator.insertActive(containerdID, funcInst)
if err != nil {
log.WithError(err).Error("failed to insert active VM")
return nil, err
Expand All @@ -101,16 +101,15 @@ func (s *Service) processUserContainer(ctx context.Context, r *criapi.CreateCont
return stockResp, stockErr
}

func (s *Service) processQueueProxy(ctx context.Context, r *criapi.CreateContainerRequest) (*criapi.CreateContainerResponse, error) {
vmConfig, err := s.getPodConfig(r.GetPodSandboxId())
func (s *Service) createQueueProxy(ctx context.Context, r *criapi.CreateContainerRequest) (*criapi.CreateContainerResponse, error) {
vmConfig, err := s.getPodVMConfig(r.GetPodSandboxId())
if err != nil {
log.WithError(err).Error()
return nil, err
}

s.removePodConfig(r.GetPodSandboxId())
s.removePodVMConfig(r.GetPodSandboxId())

// Add guest IP and port
guestIPKeyVal := &criapi.KeyValue{Key: guestIPEnv, Value: vmConfig.guestIP}
guestPortKeyVal := &criapi.KeyValue{Key: guestPortEnv, Value: vmConfig.guestPort}
r.Config.Envs = append(r.Config.Envs, guestIPKeyVal, guestPortKeyVal)
Expand All @@ -124,34 +123,15 @@ func (s *Service) processQueueProxy(ctx context.Context, r *criapi.CreateContain
return resp, nil
}

func getGuestImagePort(config *criapi.ContainerConfig) (string, string, error) {
var (
image, port string
imageFound, portFound bool
)

func getGuestImage(config *criapi.ContainerConfig) (string, error) {
envs := config.GetEnvs()
for _, kv := range envs {
if kv.GetKey() == guestImageEnv {
image = kv.GetValue()
imageFound = true
} else if kv.GetKey() == guestPortEnv {
port = kv.GetValue()
portFound = true
return kv.GetValue(), nil
}
if imageFound && portFound {
break
}
}

// default value if port not provided
if port == "" {
port = guestPortValue
}

if image == "" || port == "" {
return "", "", errors.New("failed to provide non empty guest image and port in user container config")
}
return "", errors.New("failed to provide non empty guest image in user container config")

return image, port, nil
}
6 changes: 3 additions & 3 deletions cri/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,21 @@ func getDialOpts() []grpc.DialOption {
}
}

func (s *Service) insertPodConfig(podID string, vmConfig *VMConfig) {
func (s *Service) insertPodVMConfig(podID string, vmConfig *VMConfig) {
s.Lock()
defer s.Unlock()

s.podVMConfigs[podID] = vmConfig
}

func (s *Service) removePodConfig(podID string) {
func (s *Service) removePodVMConfig(podID string) {
s.Lock()
defer s.Unlock()

delete(s.podVMConfigs, podID)
}

func (s *Service) getPodConfig(podID string) (*VMConfig, error) {
func (s *Service) getPodVMConfig(podID string) (*VMConfig, error) {
s.Lock()
defer s.Unlock()

Expand Down
18 changes: 0 additions & 18 deletions knative_workloads/helloworld.yaml

This file was deleted.

19 changes: 0 additions & 19 deletions knative_workloads/helloworldSerial.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions knative_workloads/pyaes.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions knative_workloads/rnn_serving.yaml

This file was deleted.

10 changes: 5 additions & 5 deletions scripts/cluster/setup_master_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ kubectl apply -f - -n kube-system
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.4/manifests/namespace.yaml
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.4/manifests/metallb.yaml
kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"
kubectl apply -f $ROOT/configs/metallb-configmap.yaml
kubectl apply -f $ROOT/configs/metallb/metallb-configmap.yaml

# istio
curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.6.11 TARGET_ARCH=x86_64 sh -
./istio-1.6.11/bin/istioctl manifest apply -f $ROOT/configs/istio-minimal-operator.yaml
./istio-1.6.11/bin/istioctl manifest apply -f $ROOT/configs/istio/istio-minimal-operator.yaml


# Install KNative in the cluster
kubectl apply --filename $ROOT/knative_yamls/serving-crds.yaml
kubectl apply --filename $ROOT/knative_yamls/serving-core.yaml
kubectl apply --filename $ROOT/configs/knative_yamls/serving-crds.yaml
kubectl apply --filename $ROOT/configs/knative_yamls/serving-core.yaml

# magic DNS
kubectl apply --filename $ROOT/knative_yamls/serving-default-domain.yaml
kubectl apply --filename $ROOT/configs/knative_yamls/serving-default-domain.yaml

kubectl apply --filename https://github.com/knative/net-istio/releases/download/v0.19.0/release.yaml
kubectl --namespace istio-system get service istio-ingressgateway
2 changes: 1 addition & 1 deletion scripts/setup_containerd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT="$( cd $DIR && cd .. && pwd)"
BINS=$ROOT/bin
CONFIGS=$ROOT/configs
CONFIGS=$ROOT/configs/firecracker-containerd

sudo mkdir -p /etc/firecracker-containerd
sudo mkdir -p /var/lib/firecracker-containerd/runtime
Expand Down

0 comments on commit aa6b91a

Please sign in to comment.