Knative - k8s-based platform-as-a-service nrog serverless kev txhawb nqa

Knative - k8s-based platform-as-a-service nrog serverless kev txhawb nqa

Kubernetes tau undoubtedly dhau los ua qhov tseem ceeb platform rau kev xa khoom ntim khoom. Nws muab lub peev xwm los tswj yuav luag txhua yam uas siv nws cov APIs thiab cov tswj kev cai uas txuas ntxiv nws cov APIs nrog cov peev txheej kev cai.

Txawm li cas los xij, tus neeg siv tseem yuav tsum txiav txim siab ntxaws ntxaws txog yuav ua li cas xa, teeb tsa, tswj, thiab ntsuas cov ntawv thov. Cov teeb meem ntawm daim ntawv thov scaling, kev tiv thaiv, thiab kev khiav dej num tseem nyob ntawm tus neeg siv kev txiav txim siab. Qhov no tau teeb tsa Kubernetes sib nrug los ntawm cov txheej txheem ib txwm ua raws li kev pabcuam (PaaS), xws li Huab Foundry thiab Heroku.

Cov platforms muaj cov neeg siv yooj yim interface thiab yog tsom rau cov neeg tsim daim ntawv thov uas feem ntau koom nrog hauv kev teeb tsa ib tus neeg siv. Kev xa tawm, kev xa tawm, thiab kev ntsuas tau raug tswj kom pom tseeb rau tus neeg siv los ntawm PaaS qhov system.

Lub hauv paus-rau-nkoj workflow yog tswj los ntawm PaaS los ntawm kev tsim ib lub thawv ntim cov duab, xa nws, teeb tsa txoj kev tshiab thiab DNS subdomain rau cov tsheb khiav. Tag nrho cov no yog launched ntawm hais kom ua git push.

Kubernetes (xws li txhob txwm) tsuas yog muab cov tub ntxhais lub tsev thaiv rau cov platforms zoo li no, tawm hauv zej zog los ua haujlwm rau lawv tus kheej. Yuav ua li cas Kelsey Hightower tau hais:

Kubernetes yog lub platform tsim lub platform. Txoj haujlwm zoo tshaj plaws rau kev pib, tab sis tsis tiav.

Yog li ntawd, peb pom ib pawg ntawm Kubernetes tsim, nrog rau cov tuam txhab hosting uas tab tom sim tsim PaaS rau Kubernetes, xws li OpenShift thiab Rancher. Amid kev loj hlob Kube-PaaS kev ua lag luam, Knative, nrhiav tau hauv Lub Xya Hli 2018 los ntawm Google thiab Pivotal, tab tom nkag mus rau lub nplhaib.

Knative yog kev sib koom tes ntawm Google thiab Pivotal, nrog kev pab me ntsis los ntawm lwm lub tuam txhab xws li IBM, RedHat thiab Solo.im. Nws muab cov khoom zoo sib xws PaaS rau Kubernetes nrog kev txhawb nqa saum toj kawg nkaus rau cov ntawv thov tsis siv neeg siv computer. Tsis zoo li Kubernetes tsim, Knative tau teeb tsa ua ib qho ntxiv rau ntawm ib qho sib xws Kubernetes pawg thiab teeb tsa los ntawm cov neeg siv khoom siv.

Knative yog dab tsi?

Knative tau piav qhia tias "Lub Kubernetes-raws li platform rau kev xa thiab tswj cov haujlwm uas siv cov khoom siv niaj hnub tsis muaj kev suav." Knative, thaum them nqi nws tus kheej xws li lub platform, nquag autoscales ntim hauv kev faib ua feem rau cov kev thov HTTP concurrent. Cov kev pabcuam uas tsis tau siv thaum kawg suav mus rau xoom, muab kev pabcuam serverless-style ntawm-xav tau qhov ntsuas.

Knative muaj cov txheej txheem tswj hwm uas nruab rau hauv ib qho Kubernetes pawg thiab muab cov peev txheej hauv qab no:

  • lub tsev ntim cov ntawv thov los ntawm qhov chaws (muab los ntawm cov khoom siv Tsim kom muaj),
  • muab kev nkag mus rau kev nkag mus rau cov ntawv thov (muab los ntawm cov khoom siv Kev pab),
  • xa thiab tsis siv neeg scaling ntawm daim ntawv thov ntawm kev thov (tseem muab los ntawm cov khoom siv Kev pab),
  • txheeb xyuas qhov chaw ntawm cov xwm txheej uas ua rau cov ntawv thov xa tawm (muab los ntawm cov khoom siv Kev tshwm sim).

Ib qho tseem ceeb yog Kev Pabcuam, uas muab kev pabcuam, pib-scaling, thiab kev tswj xyuas tsheb rau kev tswj xyuas cov ntawv thov. Tom qab txhim kho Knative, koj tseem muaj kev nkag mus rau Kubernetes API tag nrho, tso cai rau cov neeg siv los tswj cov ntawv thov zoo tib yam txoj kev, thiab tseem ua haujlwm rau kev debug Knative cov kev pabcuam, ua haujlwm nrog tib API primitives uas cov kev pabcuam no siv (modules, kev pabcuam, thiab lwm yam).

Nrog kev pab los ntawm Kev Pabcuam, xiav-ntsuab kev tsheb khiav tsheb kuj tseem siv tau, ua kom muaj kev sib cais ntawm cov tshiab thiab qub ntawm daim ntawv thov thaum tus neeg siv xa cov hloov tshiab ntawm daim ntawv thov.

Knative nws tus kheej nyob ntawm kev txhim kho lub ingress maub los tau tshaj. Thaum lub sijhawm sau ntawv no tau txais kev txhawb nqa Gloo API Gateway ΠΈ Istio Service Mesh. Nws yuav teeb tsa muaj kev nkag mus rau kev khiav tsheb mus rau Knative-tswj daim ntawv thov.

Istio Service Mesh tuaj yeem yog qhov kev vam khom loj rau cov neeg siv Knative xav sim nws yam tsis tau txhim kho Istio tswj vaj huam sib luag, txij li Knative tsuas yog nyob ntawm lub rooj vag.

Vim li no, cov neeg siv feem ntau nyiam Gloo ua lub qhov rooj rau Knative, muab cov txheej txheem zoo sib xws rau Istio (rau lub hom phiaj ntawm kev siv Knative nkaus xwb), thaum tseem siv cov peev txheej tsawg thiab muaj cov nqi qis dua.

Cia peb sim Knative hauv kev nqis tes ua ntawm qhov muag. Kuv mam li yuav siv ib pawg tshiab uas tau teeb tsa ua haujlwm hauv GKE:

kubectl get namespace
NAME          STATUS   AGE
default       Active   21h
kube-public   Active   21h
kube-system   Active   21h

Cia peb pib txhim kho Knative thiab Gloo. Qhov no tuaj yeem ua tiav hauv txhua qhov kev txiav txim:

# ставим Knative-Serving
kubectl apply -f 
 https://github.com/knative/serving/releases/download/v0.8.0/serving-core.yaml
namespace/knative-serving created
# ...
# ставим Gloo
kubectl apply -f 
  https://github.com/solo-io/gloo/releases/download/v0.18.22/gloo-knative.yaml
namespace/gloo-system created
# ...

Peb xyuas tias tag nrho cov Pods nyob rau hauv "Running" xwm txheej:

kubectl get pod -n knative-serving
NAME                              READY   STATUS    RESTARTS   AGE
activator-5dd55958cc-fkp7r        1/1     Running   0          7m32s
autoscaler-fd66459b7-7d5s2        1/1     Running   0          7m31s
autoscaler-hpa-85b5667df4-mdjch   1/1     Running   0          7m32s
controller-85c8bb7ffd-nj9cs       1/1     Running   0          7m29s
webhook-5bd79b5c8b-7czrm          1/1     Running   0          7m29s
kubectl get pod -n gloo-system
NAME                                      READY   STATUS    RESTARTS   AGE
discovery-69548c8475-fvh7q                1/1     Running   0          44s
gloo-5b6954d7c7-7rfk9                     1/1     Running   0          45s
ingress-6c46cdf6f6-jwj7m                  1/1     Running   0          44s
knative-external-proxy-7dd7665869-x9xkg   1/1     Running   0          44s
knative-internal-proxy-7775476875-9xvdg   1/1     Running   0          44s

Gloo npaj txhij rau txoj kev, cia peb tsim qhov pib-scaling Knative kev pabcuam (cia hu nws kservice) thiab txoj kev tsheb mus rau nws.

Cov kev pabcuam Knative muab txoj hauv kev yooj yim dua rau kev xa cov ntawv thov rau Kubernetes dua li cov qauv xa tawm + Kev Pabcuam + Ingress qauv. Peb yuav ua haujlwm nrog qhov piv txwv no:

apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
 name: helloworld-go
 namespace: default
spec:
 template:
   spec:
     containers:
       - image: gcr.io/knative-samples/helloworld-go
         env:
           - name: TARGET
             Value: Knative user

Kuv tau theej qhov no mus rau ib cov ntaub ntawv, tom qab ntawd siv nws rau kuv lub Kubernetes pawg li no:

kubectl apply -f ksvc.yaml -n default

Peb tuaj yeem saib cov peev txheej tsim los ntawm Knative hauv pawg tom qab xa peb 'helloworld-go' kev pabcuam:

kubectl get pod -n default
NAME                                              READY   STATUS    RESTARTS   AGE
helloworld-go-fjp75-deployment-678b965ccb-sfpn8   2/2     Running   0          68s

Lub taub hau nrog peb 'helloworld-go' duab yog launched thaum lub kservice yog deployed. Yog tias tsis muaj tsheb khiav, tus naj npawb ntawm cov pods yuav raug txo kom xoom. Thiab vice versa, yog hais tias tus naj npawb ntawm ib txhij thov tshaj ib tug tej yam configurable pib, tus naj npawb ntawm cov pods yuav nce.

kubectl get ingresses.networking.internal.knative.dev -n default
NAME            READY   REASON
helloworld-go   True

Knative teeb tsa nws cov ingress siv qhov tshwj xeeb 'ingress' cov peev txheej hauv Knative API sab hauv. Gloo siv qhov API no raws li nws qhov kev teeb tsa los muab cov yam ntxwv zoo li PaaS, suav nrog cov qauv xa tawm xiav-ntsuab, tsis siv neeg TLS kev tswj hwm, ncua sijhawm, thiab lwm yam kev ua haujlwm siab heev.

Tom qab qee lub sijhawm, peb pom tias peb cov pods tau ploj mus (vim tias tsis muaj tsheb thauj mus los):

kubectl get pod -n default

No resources found.
kubectl get deployment -n default
NAME                             DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
helloworld-go-fjp75-deployment   0         0         0            0           9m46s

Thaum kawg peb yuav sim mus cuag lawv. Koj tuaj yeem yooj yim thiab yooj yim tau txais qhov URL rau Knative Proxy siv glooctl:

glooctl proxy url --name knative-external-proxy
http://35.190.151.188:80

Tsis ntsia glooctl koj tuaj yeem pom qhov chaw nyob thiab chaw nres nkoj hauv kube kev pabcuam:

kubectl get svc -n gloo-system knative-external-proxy
NAME                     TYPE           CLUSTER-IP     EXTERNAL-IP      PORT(S)                      AGE
knative-external-proxy   LoadBalancer   10.16.11.157   35.190.151.188   80:32168/TCP,443:30729/TCP   77m

Cia peb khiav qee cov ntaub ntawv siv cURL:

curl -H "Host: helloworld-go.default.example.com" http://35.190.151.188
Hello Knative user!

Knative muab ib qho yuav luag-PaaS rau cov neeg tsim khoom nyob rau sab saum toj ntawm Kubernetes tawm ntawm lub thawv siv Gloo qhov kev ua tau zoo, tag nrho-pawg API rooj vag. Cov ntawv tshaj tawm no tsuas yog khawb qhov chaw ntawm Knative qhov kev xaiv kho kom haum thiab cov yam ntxwv ntxiv. Ib yam nrog Gloo!

Txawm tias muaj tseeb tias Knative tseem yog ib txoj haujlwm hluas, nws pab neeg tau tshaj tawm cov ntawv tshiab txhua rau lub lis piam, thiab kev siv cov yam ntxwv siab heev tau pib, xws li kev siv TLS tsis siv neeg, tsis siv neeg scaling ntawm cov tswj vaj huam sib luag. Muaj lub caij nyoog zoo uas, vim muaj kev sib koom tes ntawm ntau lub tuam txhab huab, thiab raws li lub hauv paus ntawm Google's Cloud Run tshiab muab, Knative tuaj yeem dhau los ua qhov kev xaiv tseem ceeb rau serverless xam thiab PaaS ntawm Kubernetes. Ua raws li xov xwm!

Los ntawm Editors ntawm SouthBridge
Cov neeg nyeem cov kev xav yog qhov tseem ceeb rau peb, yog li peb thov kom koj koom nrog hauv kev tshawb fawb luv luv hais txog yav tom ntej cov ntawv hais txog Knative, Kubernetes, serverless xam:

Tsuas yog cov neeg siv sau npe tuaj yeem koom nrog hauv daim ntawv ntsuam xyuas. Kos npe rau hauvthov.

Kuv puas yuav tsum tau sau ntawv txuas ntxiv thiab cov lus qhia txog Knative thiab serverless xam?

  • Yog thov.

  • Tsis yog, ua tsaug.

28 cov neeg siv pov npav. 4 cov neeg siv tau txwv.

Tau qhov twg los: www.hab.com

Ntxiv ib saib