Created
April 15, 2019 22:29
-
-
Save erhwenkuo/0c345c19fb2113607ab6fa309303442e to your computer and use it in GitHub Desktop.
Kubernetes Ingress & Ingress Controller 範例#1 (app1)
This file contains hidden or 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
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: app1-deployment | |
namespace: default | |
labels: | |
app: app1 | |
spec: | |
replicas: 3 | |
selector: | |
matchLabels: | |
app: app1 | |
template: | |
metadata: | |
labels: | |
app: app1 | |
spec: | |
containers: | |
- name: app1 | |
image: "witlab/ingress-training-app1:v0.1" | |
imagePullPolicy: IfNotPresent | |
ports: | |
- name: http | |
containerPort: 8080 | |
protocol: TCP | |
resources: | |
{} |
This file contains hidden or 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
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: app1-service | |
namespace: default | |
labels: | |
app: app1 | |
spec: | |
type: ClusterIP | |
ports: | |
- port: 80 | |
targetPort: http | |
protocol: TCP | |
name: http | |
selector: | |
app: app1 |
This file contains hidden or 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
apiVersion: extensions/v1beta1 | |
kind: Ingress | |
metadata: | |
name: app1-ing | |
namespace: default | |
labels: | |
app: app1 | |
spec: | |
rules: | |
- host: app1.example.com | |
http: | |
paths: | |
- path: / | |
backend: | |
serviceName: app1-service | |
servicePort: http |
This file contains hidden or 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
From busybox:glibc | |
RUN mkdir -p /root/workplace | |
COPY ./app1 /root/workplace/app1 | |
RUN chmod +x /root/workplace/app1 | |
WORKDIR /root/workplace | |
ENTRYPOINT ["/root/workplace/app1"] |
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
) | |
func handler(w http.ResponseWriter, r *http.Request) { | |
log.Println("receive a request") | |
fmt.Fprintf(w, "<h1>Hello, I am app1!</h1> Developed using <b>Golang</b>") | |
} | |
func main() { | |
http.HandleFunc("/", handler) | |
http.ListenAndServe(":8080", nil) | |
} |
This file contains hidden or 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
## usage: make build repos=xxxx tag=v0.1 | |
# default | |
repos=docker.io/witlab/ingress-training-app1 | |
tag=v0.1 | |
all: push | |
build: | |
GOOS=linux GOARCH=amd64 go build -o app1 main.go | |
buildimage: build | |
docker build -t $(repos):$(tag) . | |
push: buildimage | |
docker push $(repos):$(tag) | |
pull: | |
docker pull $(repos):$(tag) | |
test: | |
go test -v ./... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment