Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
denverdino committed May 3, 2018
0 parents commit f137c98
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 0 deletions.
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
## Serverless Kubernetes Examples

[Serverless Kubernetes](https://www.aliyun.com/product/kubernetes) is part of Container Service for Alibaba Cloud. It enable you to run Kubernetes application without effort for managing servers or clusters. Serverless Kubernetes lets you focus on building your applications instead of managing the infrastructure.

This directory contains a number of examples of how to run real applications with Serverless Kubernetes of Alibaba Cloud


## Quick Start

Create the Serverless Kubernetes and copy the cluster config file to ```~/.kube/config```

![image-20180503115812022](/Users/yili/work/serverless-k8s-examples/cluster.png)



![config](/Users/yili/work/serverless-k8s-examples/config.png)



## Test it Out



Deploy nginx application

```
kubectl run nginx --image nginx:1.13 --replicas=3
```

Expose nginx with Elastic Load Balancer(ELB) service

```
kubectl expose deployment nginx --port=80 --target-port=80 --name=nginx-svc --type=LoadBalancer
```


Get the application status

```
kubectl get deployment nginx
kubectl get pod -l run=nginx
kubectl get service nginx-svc
```

Access nginx application

```
LB_ENDPOINT=$(kubectl get service nginx-svc -o jsonpath="{.status.loadBalancer.ingress[*].ip}")
# Open browser with URL in MacOSX
open http://${LB_ENDPOINT}
```


Delete the nginx application

```
kubectl delete deploy nginx
```

Delete the nginx service

```
kubectl delete --name=nginx-svc
```
Binary file added cluster.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions javaweb-tomcat-sidecar/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## Java Web Application with Tomcat and Sidecar Container

The following document describes the deployment of a Java Web application using Tomcat. Instead of packaging `war` file inside the Tomcat image or mount the `war` as a volume, we use a sidecar container as `war` file provider.

The orginal example is from Kubernetes examples project

https://github.com/kubernetes/examples/blob/master/staging/javaweb-tomcat-sidecar/

## Test It Out

Deploy application

```
kubectl apply -f javaweb.yaml
```

Check status of the deployments/pods/services:

```
kubectl get all
```

Check the external endpoint for load balancer

```
kubectl get svc tomcat-app-svc
```

Access the sample application

```
LB_ENDPOINT=$(kubectl get service tomcat-app-svc -o jsonpath="{.status.loadBalancer.ingress[*].ip}")
# Open browser with URL in MacOSX
open http://${LB_ENDPOINT}:8080/sample/
```

Delete application


```
kubectl delete -f javaweb.yaml
```
60 changes: 60 additions & 0 deletions javaweb-tomcat-sidecar/javaweb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
apiVersion: v1
kind: Service
metadata:
name: tomcat-app-svc
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 8080
selector:
app: tomcat-app
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tomcat-app
labels:
app: tomcat-app
spec:
replicas: 1
selector:
matchLabels:
app: tomcat-app
template:
metadata:
labels:
app: tomcat-app
spec:
initContainers:
- image: resouer/sample:v2
name: war
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /app
name: app-volume
command:
- "cp"
- "-r"
- "/sample.war"
- "/app"
containers:
- image: tomcat:8-jre8-alpine
name: tomcat
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /usr/local/tomcat/webapps
name: app-volume
ports:
- containerPort: 8080
resources:
requests:
memory: "256Mi"
cpu: "500m"
limits:
memory: "256Mi"
cpu: "500m"
volumes:
- name: app-volume
emptyDir: {}

0 comments on commit f137c98

Please sign in to comment.