forked from AliyunContainerService/serverless-k8s-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f137c98
Showing
5 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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``` | ||
|
||
 | ||
|
||
|
||
|
||
 | ||
|
||
|
||
|
||
## 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 | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: {} |