2018년 7월 출시된 새로운 프로젝트
제품 3가지 및 기능
knative 장점
istio와 연동
knative 구성
apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
name: "helloworld"
spec:
runLatest:
configuration:
revisionTemplate:
spec:
container:
image: "gcr.io/knative-samples/helloworld-go"
env:
- name: "TARGET"
value: "world"
kubectl get configuration,revision,route
NAME CREATED AT
configuration.serving.knative.dev/helloworld 28m
NAME CREATED AT
revision.serving.knative.dev/helloworld-00001 28m
NAME CREATED AT
route.serving.knative.dev/helloworld 28m
istio gateway를 통해 들어오는 traffaic을 받기위한 정의 및 확인
Istio사용 설정
knative 앱 설정
테스트 및 확인 방법
blue/green deploy라고 하면, 배포 전략으로 새로운 버전의 어플리케이션이을 만들었을때, 일부 트래픽을 version2(green)로 보내면서 운영환경에서 문제가 없는지 체크하고, 트래픽을 증가시키면서 Version2로 완전히 변경시키는 방법론이다
이를 테스트 하기위해서는 yaml을 수정할 부분이 있다
최초 v1배포
apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
name: canary
spec:
runLatest:
configuration:
revisionTemplate:
spec:
container:
image: gcr.io/knative-samples/knative-route-demo:blue
env:
- name: T_VERSION
value: "blue"
배포 후 revision이름이 canary-0001(가칭)로 배포된것을 확인해 볼수 있다
v2와 함께 blue/green 배포
apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
name: canary
spec:
release:
revisions: ["canary-00001", "canary-00002"] # [current, candidate]
rolloutPercent: 20 # 20% to green revision
configuration:
revisionTemplate:
spec:
container:
image: gcr.io/knative-samples/knative-route-demo:green
env:
- name: T_VERSION
value: "green"
kubectl describe route canary
...
Status:
Traffic:
Name: current
Percent: 80
Revision Name: canary-00001
Name: candidate
Percent: 20
Revision Name: canary-00002
Name: latest
Percent: 0
Revision Name: canary-00002
apiVersion: build.knative.dev/v1alpha1
kind: Build
metadata:
name: example-build
spec:
source:
git:
url: "https://github.com/knative/docs.git"
revision: "v0.1.x"
subPath: "serving/samples/helloworld-go/"
steps:
- name: build-and-push
image: "gcr.io/kaniko-project/executor:v0.6.0"
args:
- "--dockerfile=/workspace/Dockerfile"
- "--destination=gcr.io/<your-project-id>/helloworld-go:v1"
내부적으로 단계를 가지는데...
BuildTemplate, ClusterBuildTemplate
apiVersion: build.knative.dev/v1alpha1
kind: BuildTemplate
metadata:
name: kaniko
spec:
parameters:
- name: IMAGE
description: name of the image to be tagged and pushed
steps:
- name: build-and-push
image: "gcr.io/kaniko-project/executor:v0.6.0"
args: ["--destination=${IMAGE}"]
---
apiVersion: build.knative.dev/v1alpha1
kind: Build
metadata:
name: templatized-build
spec:
source:
git:
url: "https://github.com/knative/docs.git"
revision: "v0.1.x"
subPath: "serving/samples/helloworld-go/"
template:
name: kaniko
arguments:
- name: IMAGE
value: "gcr.io/<your-project-id>/helloworld-go:v2"
https://codelabs.developers.google.com/codelabs/knative-intro#0