Skip to content

Serverless & FaaS 실습

kimsanghoon1 edited this page Dec 31, 2018 · 4 revisions
istio 가 설치되어 있어야한다.

istio가 설치 된 상태일 경우

> kubectl label namespace default istio-injection=enabled
> kubectl apply --filename https://github.com/knative/serving/releases/download/v0.2.2/release.yaml

만약 istio가 설치 안된 상태라면 추가 작업

> kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin --user=$(gcloud config get-value core/account)
> kubectl apply --filename https://github.com/knative/serving/releases/download/v0.2.2/istio.yaml

설치확인

> kubectl get pods --namespace knative-serving
> kubectl get pods --namespace knative-build

디플로이

> nano service.yaml
apiVersion: serving.knative.dev/v1alpha1 # Current version of Knative
kind: Service
metadata:
  name: helloworld-go # The name of the app
  namespace: default # The namespace the app will use
spec:
  runLatest:
    configuration:
      revisionTemplate:
        spec:
          container:
            image: gcr.io/knative-samples/helloworld-go # The URL to the image of the app
            env:
              - name: TARGET # The environment variable printed out by the sample app
                value: "Go Sample v1"
> kubectl create -f service.yaml

연결해보기

> kubectl get svc knative-ingressgateway --namespace istio-system  # ingress 접속 정보 얻기
> kubectl get ksvc helloworld-go  --output=custom-columns=NAME:.metadata.name,DOMAIN:.status.domain
> curl -H "Host: helloworld-go.default.example.com" http://${IP_ADDRESS}

기대출력

Hello World: Go Sample v1!

해킹

> kubectl get virtualservice helloworld-go-clphn -o yaml -n knative-serving
Clone this wiki locally