ΠΡΠ° ΡΡΠ°ΡΡΡ Π·Π°ΠΊΠ°Π½ΡΠΈΠ²Π°Π΅Ρ ΡΠΈΠΊΠ» ΠΏΠ΅ΡΠ΅Π²ΠΎΠ΄Π½ΡΡ
Π·Π°ΠΌΠ΅ΡΠΎΠΊ ΠΎΠ± OpenWhisk ΠΎΡ Π°Π²ΡΠΎΡΠ°
Π Π°Π·Π²ΠΎΡΠ°ΡΠΈΠ²Π°Π΅ΠΌ OpenWhisk Π½Π° Kubernetes
ΠΠ° Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ Π΄Π½Π΅ΠΉ Ρ ΠΏΡΠΎΠ²Π΅Π»Π° ΡΠΊΡΠΏΠ΅ΡΠΈΠΌΠ΅Π½Ρ ΠΏΠΎ ΡΠ°Π·Π²Π΅ΡΡΡΠ²Π°Π½ΠΈΡ OpenWhisk Π² Kubernetes Π΄Π»Ρ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ ΠΏΡΠΎΡΡΠΎΠ³ΠΎ ΠΈ Π±ΡΡΡΡΠΎΠ³ΠΎ ΠΏΠΎΠ»ΠΈΠ³ΠΎΠ½Π° Π΄Π»Ρ ΠΎΡΡΠ°Π±ΠΎΡΠΊΠΈ Π·Π°Π΄Π°Ρ. Π ΠΏΠΎΡΠΊΠΎΠ»ΡΠΊΡ Ρ Π½ΠΎΠ²ΠΈΡΠΎΠΊ Π² Kubernetes β ΠΏΠΎΠ»Π°Π³Π°Ρ, ΡΡΠΎ ΠΏΠΎΠ»ΡΠΎΡΠ° Π΄Π½Ρ Π±ΡΠ»ΠΎ ΠΏΠΎΡΡΠ°ΡΠ΅Π½ΠΎ Π½Π° ΡΡΠΏΠ΅ΡΠ½ΠΎΠ΅ ΡΠ°Π·Π²Π΅ΡΡΡΠ²Π°Π½ΠΈΠ΅. Π
- Π£ΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π΅ΠΌ ΠΏΠ°ΠΊΠ΅ΡΠ½ΡΠΉ ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅Ρ
asdf
, ΠΏΠΎΡΠ»Π΅ ΡΠ΅Π³ΠΎ Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈ ΠΈΡΠΏΡΠ°Π²Π»ΡΠ΅ΠΌ~/.bash_profile
ΠΈΠ»ΠΈ Π΅Π³ΠΎ Π°Π½Π°Π»ΠΎΠ³ ΡΠ°ΠΊ:
$ brew install asdf
$ [ -s "/usr/local/opt/asdf/asdf.sh" ] && . /usr/local/opt/asdf/asdf.sh
$ source ~/.bash_profile
[ΠΠ° Linux ΡΡΠΎΡ ΡΠ°Π³ Π½Π΅ Π½ΡΠΆΠ΅Π½, Ρ
ΠΎΡΡ brew Π΅ΡΡΡ. β ΠΏΡΠΈΠΌ. ΠΏΠ΅ΡΠ΅Π²ΠΎΠ΄ΡΠΈΠΊΠ°]
- ΠΠΎΠ±Π°Π²Π»ΡΠ΅ΠΌ ΠΏΠ»Π°Π³ΠΈΠ½Ρ
minikube
ΠΈkubelet
:
$ asdf plugin-add kubectl
$ asdf plugin-add minikube
[ΠΠΏΡΡΡ ΠΆΠ΅ ΠΏΡΠΎΠΏΡΡΠΊΠ°Π΅ΠΌ ΡΡΠΎΡ ΡΠ°Π³ Π½Π° Linux. β ΠΏΡΠΈΠΌ. ΠΏΠ΅ΡΠ΅Π²ΠΎΠ΄ΡΠΈΠΊΠ°]
- Π‘ΡΠ°Π²ΠΈΠΌ minikube ΠΈ kubelet:
$ asdf install kubectl 1.9.0
$ asdf global kubectl 1.9.0
$ asdf install minikube 0.25.2
$ asdf global minikube 0.25.2
[ΡΡΠ°Π²ΡΡΡΡ ΠΊΠΎΠ½ΠΊΡΠ΅ΡΠ½ΡΠ΅ Π²Π΅ΡΡΠΈΠΈ, Π½ΠΎ Ρ ΠΏΡΠΎΠ²Π΅ΡΡΠ» Π²ΡΠ΅ Π½Π° ΠΏΠΎΡΠ»Π΅Π΄Π½ΠΈΡ
Π΄ΠΎΡΡΡΠΏΠ½ΡΡ
Π²Π΅ΡΡΠΈΡΡ
Π΄Π»Ρ Linux; ΠΏΠΎΠ΄ΠΎΠ·ΡΠ΅Π²Π°Ρ, ΡΡΠΎ ΠΌΠΎΠΆΠ½ΠΎ ΡΠΌΠ΅Π»ΠΎ ΡΡΠ°Π²ΠΈΡΡ latest. β ΠΏΡΠΈΠΌ. ΠΏΠ΅ΡΠ΅Π²ΠΎΠ΄ΡΠΈΠΊΠ°]
ΠΠ° Linux ΡΡΠΎΡ ΡΠ°Π³ Π΄Π΅Π»Π°Π΅ΡΡΡ ΠΏΡΠΈΠΌΠ΅ΡΠ½ΠΎ ΡΠ°ΠΊ (Π²ΡΠ΅ ΡΡΠ°Π²ΠΈΡΡΡ Π² ~/bin, ΠΊΠΎΡΠΎΡΡΠΉ Ρ ΠΌΠ΅Π½Ρ ΠΏΡΠΎΠΏΠΈΡΠ°Π½ Π² PATH, ΠΏΡΠΈΠΌ. ΠΏΠ΅ΡΠ΅Π²ΠΎΠ΄ΡΠΈΠΊΠ°):
$ curl -L0 minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && mv minikube ~/bin/
$ curl -L0 https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && mv kubectl ~/bin/
- Π‘ΠΎΠ·Π΄Π°Π΅ΠΌ Π²ΠΈΡΡΡΠ°Π»ΡΠ½ΡΡ ΠΌΠ°ΡΠΈΠ½Ρ minikube (Π΄ΠΎΠ»ΠΆΠ΅Π½ Π±ΡΡΡ ΠΏΡΠ΅Π΄Π²Π°ΡΠΈΡΠ΅Π»ΡΠ½ΠΎ ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½ VirtualBox):
$ minikube start --cpus 2 --memory 4096 --kubernetes-version=v1.9.0 --extra-config=apiserver.Authorization.Mode=RBAC
[Π£ ΠΌΠ΅Π½Ρ Π²ΡΠ΅ ΡΠ°Π±ΠΎΡΠ°Π΅Ρ Ρ ΠΊΠΎΠΌΠ°Π½Π΄ΠΎΠΉ minikube start
, Π±Π΅Π· ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΠΎΠ² ΠΈ ΡΠΎ Π·Π½Π°ΡΠ΅Π½ΠΈΡΠΌΠΈ ΠΏΠΎ-ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ. β ΠΏΡΠΈΠΌ. ΠΏΠ΅ΡΠ΅Π²ΠΎΠ΄ΡΠΈΠΊΠ°]
$ minikube start
minikube v1.5.2 on Debian 8.11
Automatically selected the 'virtualbox' driver
Downloading VM boot image ...
> minikube-v1.5.1.iso.sha256: 65 B / 65 B [--------------] 100.00% ? p/s 0s
> minikube-v1.5.1.iso: 143.76 MiB / 143.76 MiB [-] 100.00% 5.63 MiB p/s 26s
Creating virtualbox VM (CPUs=2, Memory=4096MB, Disk=20000MB) ...
Preparing Kubernetes v1.16.2 on Docker '18.09.9' ...
Downloading kubelet v1.16.2
Downloading kubeadm v1.16.2
Pulling images ...
Launching Kubernetes ... Waiting for: apiserver
Done! kubectl is now configured to use "minikube"
- ΠΠ΅ΡΠ΅ΠΊΠ»ΡΡΠ°Π΅ΠΌ ΡΠ΅ΡΡ Π² Docker Π² Π½Π΅ΡΠ°Π·Π±ΠΎΡΡΠΈΠ²ΡΠΉ ΡΠ΅ΠΆΠΈΠΌ:
$ minikube ssh -- sudo ip link set docker0 promisc on
- Π‘ΠΎΠ·Π΄Π°Π΅ΠΌ namespace ΠΈ ΠΏΠΎΠΌΠ΅ΡΠ°Π΅ΠΌ ΡΠ°Π±ΠΎΡΠΈΠΉ ΡΠ·Π΅Π»:
$ kubectl create namespace openwhisk
$ kubectl label nodes --all openwhisk-role=invoker
- ΠΠΎΠ»ΡΡΠ°Π΅ΠΌ ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΠΎΠ΅ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΡ ΠΈ ΠΏΠ΅ΡΠ΅ΠΎΠΏΡΠ΅Π΄Π΅Π»ΡΠ΅ΠΌ ΡΠΈΠΏ Π΄Π»Ρ ingress Π² ΡΠ°ΠΉΠ»Π΅ mycluster.yaml:
$ git clone https://github.com/apache/incubator-openwhisk-deploy-kube.git
$ cd incubator-openwhisk-deploy-kube/
$ cat << "EOF" > mycluster.yaml
whisk:
ingress:
type: NodePort
api_host_name: 192.168.99.100
api_host_port: 31001
nginx:
httpsNodePort: 31001
EOF
- Π£ΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π΅ΠΌ Helm ΠΈ ΠΏΡΠΎΠ²ΠΎΠ΄ΠΈΠΌ ΡΠ°Π·Π²Π΅ΡΡΡΠ²Π°Π½ΠΈΠ΅ Ρ Π΅Π³ΠΎ ΠΏΠΎΠΌΠΎΡΡΡ:
$ brew install kubernetes-helm
$ helm init # init Helm Tiller, Π½Π΅ Π½ΡΠΆΠ½ΠΎ Π½Π° Helm v3+
$ kubectl get pods -n kube-system # verify that tiller-deploy is in the running state, Π½Π΅ Π½ΡΠΆΠ½ΠΎ Π½Π° helm v3+
$ kubectl create clusterrolebinding tiller-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-system:default
$ helm install ./openwhisk/helm/ --namespace=openwhisk -f mycluster.yaml
[ΠΠ° Linux Ρ ΠΏΠΎΡΠ»Π΅Π΄Π½ΠΈΠΌΠΈ Π²Π΅ΡΡΠΈΡΠΌΠΈ (Π±ΡΠ»Π° Π΄ΠΎΡΡΡΠΏΠ½Π° v3.0.1) Π±ΡΠ΄Π΅Ρ ΡΡΡΡ ΠΏΠΎ-Π΄ΡΡΠ³ΠΎΠΌΡ. β ΠΏΡΠΈΠΌ. ΠΏΠ΅ΡΠ΅Π²ΠΎΠ΄ΡΠΈΠΊΠ°]
$ curl -L0 https://get.helm.sh/helm-v3.0.1-linux-amd64.tar.gz | tar -xzvf - linux-amd64/helm --strip-components=1; sudo mv helm /usr/local/bin
$ kubectl create clusterrolebinding tiller-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-system:default
$ helm install ./openwhisk/helm/ --namespace=openwhisk --generate-name -f mycluster.yaml
- ΠΡΠΎΠ²Π΅ΡΡΠ΅ΠΌ, ΡΡΠΎ Π²ΡΠ΅ ΠΏΠΎΠ΄Π½ΡΠ»ΠΎΡΡ (STATUS = Running ΠΈΠ»ΠΈ Completed):
$ kubectl get pods -n openwhisk
NAME READY STATUS RESTARTS AGE
openwhisk-1576070780-alarmprovider-6868dc694-plvpf 1/1 Running 1 1d5h
openwhisk-1576070780-apigateway-8d56f4979-825hf 1/1 Running 1 1d5h
openwhisk-1576070780-cloudantprovider-544bb46596-9scph 1/1 Running 1 1d5h
openwhisk-1576070780-controller-0 1/1 Running 2 1d5h
openwhisk-1576070780-couchdb-7fd7f6c7cc-42tw6 1/1 Running 1 1d5h
openwhisk-1576070780-gen-certs-z9nsb 0/1 Completed 0 1d5h
openwhisk-1576070780-init-couchdb-r2vmt 0/1 Completed 0 1d5h
openwhisk-1576070780-install-packages-27dtr 0/1 Completed 0 1d4h
openwhisk-1576070780-invoker-0 1/1 Running 1 1d5h
openwhisk-1576070780-kafka-0 1/1 Running 1 1d5h
openwhisk-1576070780-kafkaprovider-f8b4cf4fc-7z4gt 1/1 Running 1 1d5h
openwhisk-1576070780-nginx-6dbdbf69bc-5x76n 1/1 Running 1 1d5h
openwhisk-1576070780-redis-cfd8756f4-hkrt6 1/1 Running 1 1d5h
openwhisk-1576070780-wskadmin 1/1 Running 1 1d5h
openwhisk-1576070780-zookeeper-0 1/1 Running 1 1d5h
wskopenwhisk-1576070780-invoker-00-1-prewarm-nodejs10 1/1 Running 0 61s
wskopenwhisk-1576070780-invoker-00-2-prewarm-nodejs10 1/1 Running 0 61s
wskopenwhisk-1576070780-invoker-00-3-whisksystem-invokerhealtht 1/1 Running 0 59s
- ΠΠ°ΡΡΡΠ°ΠΈΠ²Π°Π΅ΠΌ wsk Π΄Π»Ρ ΡΠ°Π±ΠΎΡΡ:
$ wsk property set --apihost 192.168.99.100:31001
$ wsk property set --auth 23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP
ΠΡΠΎΠ²Π΅ΡΡΠ΅ΠΌ:
$ wsk -i list
Entities in namespace: default
packages
actions
triggers
rules
ΠΡΠΎΠ±Π»Π΅ΠΌΡ ΠΈ ΠΈΡ ΡΠ΅ΡΠ΅Π½ΠΈΡ
getsockopt: connection refused
$ wsk -i list
error: Unable to obtain the list of entities for namespace 'default': Get http://192.168.99.100:31001/api/v1/namespaces/_/actions?limit=0&skip=0: dial tcp 192.168.99.100:31001: getsockopt: connection refused
ΠΡΠΎΠ²Π΅ΡΡΠ΅ΠΌ, ΡΡΠΎ ΠΊΠΎΠ½ΡΠ΅ΠΉΠ½Π΅ΡΡ Π² namespace openwhisk
Π² ΡΡΠ°ΡΡΡΠ΅ Running
, Ρ.ΠΊ. ΠΈΠ½ΠΎΠ³Π΄Π° ΠΎΠ½ΠΎ ΠΏΠ°Π΄Π°Π΅Ρ Ρ ΠΎΡΠΈΠ±ΠΊΠ°ΠΌΠΈ CreateContainerConfigError
.
Invoker still initializing β Init:1/2
ΠΡΠΎΡΠ΅ΡΡ ΡΠΊΠ°ΡΠΈΠ²Π°Π½ΠΈΡ Π²ΡΠ΅Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΡΡ
ΡΡΠ΅Π΄ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ ΠΌΠΎΠΆΠ΅Ρ Π·Π°Π½ΡΡΡ ΠΌΠ½ΠΎΠ³ΠΎ Π²ΡΠ΅ΠΌΠ΅Π½ΠΈ. ΠΠ»Ρ ΡΡΠΊΠΎΡΠ΅Π½ΠΈΡ ΠΌΠΎΠΆΠ½ΠΎ ΡΠΊΠ°Π·Π°ΡΡ ΡΠΎΠΊΡΠ°ΡΠ΅Π½Π½ΡΠΉ ΠΌΠΈΠ½ΠΈΠΌΠ°Π»ΡΠ½ΡΠΉ ΡΠΏΠΈΡΠΎΠΊ Π² ΡΠ°ΠΉΠ»Π΅ mycluster.yaml
:
whisk:
runtimes: "runtimes-minimal-travis.json"
ΠΠΎΠ½ΡΠ΅ΠΉΠ½Π΅Ρ Ρ ΠΈΠΌΠ΅Π½Π΅ΠΌ -install-packages- Π²ΡΠ²Π°Π»ΠΈΠ²Π°Π΅ΡΡΡ Π² Error
ΠΡΠΎΡΡΠΎ Π½Π°ΡΠ°ΡΡΠΈΡΠ΅ ΡΠ°ΠΉΠΌΠ°ΡΡΡ Π΄Π»Ρ liveness ΡΠ΅ΡΡΠΎΠ².
Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ° OpenWhisk ΠΏΠΎΠ²Π΅ΡΡ Knative
Priti Desai ΠΏΡΠΎΠ²ΠΎΠ΄ΠΈΠ»Π° ΡΡΡΠ°Π½ΠΎΠ²ΠΊΡ ΠΏΠΎΠ²Π΅ΡΡ
ΠΊΠ»Π°ΡΡΠ΅ΡΠ° Π² ΠΎΠ±Π»Π°ΠΊΠ΅ IBM, Π° ΡΠ°ΠΊΠΆΠ΅ Π½Π° ΠΎΠ±ΡΡΠ½ΠΎΠΌ minikube, ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΡ Knative Build ΠΈ BuildTemplates. Π― ΡΠΎΠΆΠ΅ Π±ΡΠ΄Ρ ΡΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°ΡΡ ΠΏΠΎΠ²Π΅ΡΡ
minukube, ΠΏΠΎ ΠΌΠΎΡΠΈΠ²Π°ΠΌ ΡΠΎΠ³ΠΎ, ΠΊΠ°ΠΊ
$ curl -L0 https://github.com/solo-io/gloo/releases/download/v1.2.10/glooctl-linux-amd64; chmod +x glooctl-linux-amd64; mv glooctl-linux-amd64 ~/bin
$ glooctl install knative
$ kubectl get pods -n knative-serving
NAME READY STATUS RESTARTS AGE
activator-77fc555665-rvrst 1/1 Running 0 2m23s
autoscaler-5c98b7c9b6-x8hh4 1/1 Running 0 2m21s
autoscaler-hpa-5cfd4f6845-w87kq 1/1 Running 0 2m22s
controller-7fd74c8f67-tprm8 1/1 Running 0 2m19s
webhook-74847bb77c-txr2g 1/1 Running 0 2m17s
$ kubectl get pods -n gloo-system
NAME READY STATUS RESTARTS AGE
discovery-859d7fbc9c-8xhvh 1/1 Running 0 51s
gloo-545886d9c6-85mwt 1/1 Running 0 51s
ingress-67d4996d75-lkkmw 1/1 Running 0 50s
knative-external-proxy-767dfd656c-wwv2z 1/1 Running 0 50s
knative-internal-proxy-6fdddcc6b5-7vqd8 1/1 Running 0 51s
Π‘Π±ΠΎΡΠΊΠ° ΠΈ ΡΠ°Π±ΠΎΡΠ° OpenWhisk ΠΏΠΎΠ²Π΅ΡΡ
Knative
- ΠΠΎΠ»ΡΡΠ°Π΅ΠΌ ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΠΎΠ΅
ΡΡΠΎΠ³ΠΎ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΡ :
$ git clone https://github.com/tektoncd/catalog/
$ cd catalog/openwhisk
- ΠΡΡΡΠ°Π²Π»ΡΠ΅ΠΌ Π² Π²ΠΈΠ΄Π΅ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ ΠΎΠΊΡΡΠΆΠ΅Π½ΠΈΡ Π΄Π°Π½Π½ΡΠ΅ Π΄Π»Ρ Π΄ΠΎΡΡΡΠΏΠ° ΠΊ Registry ΠΈ ΡΠΎΡ ΡΠ°Π½ΡΠ΅ΠΌ ΠΈΡ Π² Π²ΠΈΠ΄Π΅ ΡΠ΅ΠΊΡΠ΅ΡΠ° Kubernetes:
$ export DOCKER_USERNAME=<your docker hub username>
$ export DOCKER_PASSWORD=<your docker hub password>
$ sed -e 's/${DOCKER_USERNAME}/'"$DOCKER_USERNAME"'/' -e 's/${DOCKER_PASSWORD}/'"$DOCKER_PASSWORD"'/' docker-secret.yaml.tmpl > docker-secret.yaml
$ kubectl apply -f docker-secret.yaml
ΠΡΠΎΠ²Π΅ΡΡΠ΅ΠΌ:
$ kubectl get secret
NAME TYPE DATA AGE
dockerhub-user-pass kubernetes.io/basic-auth 2 21s
- Π‘ΠΎΠ·Π΄Π°Π΅ΠΌ ΡΡΠ΅ΡΠ½ΡΡ Π·Π°ΠΏΠΈΡΡ Π΄Π»Ρ ΡΠ±ΠΎΡΠΊΠΈ ΠΎΠΊΡΡΠΆΠ΅Π½ΠΈΠΉ:
$ kubectl apply -f service-account.yaml
ΠΡΠΎΠ²Π΅ΡΡΠ΅ΠΌ:
$ kubectl get serviceaccount/openwhisk-runtime-builder
NAME SECRETS AGE
openwhisk-runtime-builder 2 31m
- Π‘ΠΎΠ·Π΄Π°Π΅ΠΌ Π·Π°Π΄Π°ΡΡ Π΄Π»Ρ ΡΠ±ΠΎΡΠΊΠΈ ΠΎΠ±ΡΠ°Π·Π° Π΄Π»Ρ OpenWhisk
$ kubectl apply -f openwhisk.yaml
task.tekton.dev/openwhisk created
- ΠΠ°ΠΏΡΡΠΊΠ°Π΅ΠΌ Π·Π°Π΄Π°ΡΡ Π΄Π»Ρ ΡΠ±ΠΎΡΠΊΠΈ ΠΎΠ±ΡΠ°Π·Π° (Π½Π° ΠΏΡΠΈΠΌΠ΅ΡΠ΅ NodeJS):
Π‘ΠΎΠ·Π΄Π°Π΅ΠΌ ΡΠ°ΠΉΠ» taskrun.yaml Ρ ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΡΠΌ:
# Git Pipeline Resource for OpenWhisk NodeJS Runtime
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: openwhisk-nodejs-runtime-git
spec:
type: git
params:
- name: revision
value: master
- name: url
value: https://github.com/apache/openwhisk-runtime-nodejs.git
---
# Image Pipeline Resource for OpenWhisk NodeJS Sample Application
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: openwhisk-nodejs-helloworld-image
spec:
type: image
params:
- name: url
value: docker.io/${DOCKER_USERNAME}/openwhisk-nodejs-helloworld
---
# Task Run to build NodeJS image with the action source
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: openwhisk-nodejs-helloworld
spec:
serviceAccountName: openwhisk-runtime-builder
taskRef:
name: openwhisk
inputs:
resources:
- name: runtime-git
resourceRef:
name: openwhisk-nodejs-runtime-git
params:
- name: DOCKERFILE
value: "./runtime-git/core/nodejs10Action/knative/Dockerfile"
- name: OW_ACTION_NAME
value: "nodejs-helloworld"
- name: OW_ACTION_CODE
value: "function main() {return {payload: 'Hello World!'};}"
- name: OW_PROJECT_URL
value: ""
outputs:
resources:
- name: runtime-image
resourceRef:
name: openwhisk-nodejs-helloworld-image
---
ΠΡΠΈΠΌΠ΅Π½ΡΠ΅ΠΌ Π°ΠΊΡΡΠ°Π»ΡΠ½ΡΠ΅ Π΄Π°Π½Π½ΡΠ΅ Π΄Π»Ρ ΡΡΠΎΠ³ΠΎ ΡΠ°ΠΉΠ»Π°:
$ sed 's/${DOCKER_USERNAME}/'"$DOCKER_USERNAME"'/' -i taskrun.yaml
ΠΡΠΈΠΌΠ΅Π½ΡΠ΅ΠΌ:
$ kubectl apply -f taskrun.yaml
pipelineresource.tekton.dev/openwhisk-nodejs-runtime-git created
pipelineresource.tekton.dev/openwhisk-nodejs-helloworld-image created
taskrun.tekton.dev/openwhisk-nodejs-helloworld created
ΠΡΠΎΠ²Π΅ΡΠΊΠ° ΡΠ°Π±ΠΎΡΡ Π·Π°ΠΊΠ»ΡΡΠ°Π΅ΡΡΡ Π² ΠΏΠΎΠ»ΡΡΠ΅Π½ΠΈΠΈ ΠΈΠΌΠ΅Π½ΠΈ pod`Π°, ΠΏΡΠΎΡΠΌΠΎΡΡΠ° Π΅Π³ΠΎ ΡΡΠ°ΡΡΡΠ°. Π’Π°ΠΊΠΆΠ΅ ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠΎΡΠΌΠΎΡΡΠ΅ΡΡ ΠΆΡΡΠ½Π°Π» Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ ΡΠ°Π³Π°, Π½Π°ΠΏΡΠΈΠΌΠ΅Ρ:
$ kubectl get taskrun
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME
openwhisk-nodejs-helloworld True Succeeded 5m15s 44s
$ kubectl get pod openwhisk-nodejs-helloworld-pod-4640d3
NAME READY STATUS RESTARTS AGE
openwhisk-nodejs-helloworld-pod-4640d3 0/6 Completed 0 5m20s
$ kubectl logs openwhisk-nodejs-helloworld-pod-4640d3 -c step-git-source-openwhisk-nodejs-runtime-git-r8vhr
{"level":"info","ts":1576532931.5880227,"logger":"fallback-logger","caller":"logging/config.go:69","msg":"Fetch GitHub commit ID from kodata failed: open /var/run/ko/refs/heads/master: no such file or directory"}
{"level":"info","ts":1576532936.538926,"logger":"fallback-logger","caller":"git/git.go:81","msg":"Successfully cloned https://github.com/apache/openwhisk-runtime-nodejs.git @ master in path /workspace/runtime-git"}
{"level":"warn","ts":1576532936.5395331,"logger":"fallback-logger","caller":"git/git.go:128","msg":"Unexpected error: creating symlink: symlink /tekton/home/.ssh /root/.ssh: file exists"}
{"level":"info","ts":1576532936.8202565,"logger":"fallback-logger","caller":"git/git.go:109","msg":"Successfully initialized and updated submodules in path /workspace/runtime-git"}
ΠΠΎΡΠ»Π΅ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ Ρ Π½Π°Ρ Π² Registry ΠΏΠΎΡΠ²ΠΈΡΡΡ ΠΎΠ±ΡΠ°Π·, ΠΊΠΎΡΠΎΡΡΠΉ ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΡΠ°Π·Π²Π΅ΡΠ½ΡΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΡΡΠΈΠ»ΠΈΡΡ kn, ΠΏΡΠ΅Π΄Π½Π°Π·Π½Π°ΡΠ΅Π½Π½ΠΎΠΉ Π΄Π»Ρ ΡΠ°Π±ΠΎΡΡ Ρ Knative ΡΠ΅ΡΠ²ΠΈΡΠ°ΠΌΠΈ, Π½Π°ΠΏΡΠΈΠΌΠ΅Ρ:
kn service create nodejs-helloworld --image docker.io/${DOCKER_USERNAME}/openwhisk-nodejs-helloworld
Service 'nodejs-helloworld' successfully created in namespace 'default'.
Waiting for service 'nodejs-helloworld' to become ready ... OK
Service URL:
http://nodejs-helloworld.default.example.com
Π ΡΠ»ΡΡΠ°Π΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΡ Gloo ΠΏΡΠΎΠ²Π΅ΡΠΈΡΡ ΡΠ°Π±ΠΎΡΠΎΡΠΏΠΎΡΠΎΠ±Π½ΠΎΡΡΡ ΠΌΠΎΠΆΠ½ΠΎ ΡΠ°ΠΊ:
$ curl -H "Host: nodejs-helloworld.default.example.com" -X POST $(glooctl proxy url --name knative-external-proxy)
{"OK":true}
$ curl -H "Host: nodejs-helloworld.default.example.com" -X POST $(glooctl proxy url --name knative-external-proxy)
{"payload":"Hello World!"}
ΠΡΡΠ³ΠΈΠ΅ ΡΡΠ°ΡΡΠΈ ΡΠΈΠΊΠ»Π°
ΠΡΡΠΎΡΠ½ΠΈΠΊ: habr.com