首页 > 其他分享 >运行 Knative Serving demo 应用

运行 Knative Serving demo 应用

时间:2023-09-23 19:13:05浏览次数:44  
标签:Serving demo helloworld Knative wgs go local knative

创建 ns

# kubectl create ns knative-demo
namespace/knative-demo created

创建应用

hello-world.yaml

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: helloworld-go
  namespace: knative-demo
spec:
  template:
    spec:
      containers:
        - image: ghcr.dockerproxy.com/knative/helloworld-go:latest
          env:
            - name: TARGET
              value: "Go Sample v1"

创建资源

# kubectl apply -f hello-word.yaml
service.serving.knative.dev/hello created

查看资源

查看 Pod

# kubectl get svc,deployment,pods -n knative-demo
NAME                                  TYPE           CLUSTER-IP       EXTERNAL-IP                                        PORT(S)                                              AGE
service/helloworld-go                 ExternalName   <none>           knative-local-gateway.istio-system.svc.wgs.local   80/TCP                                               46s
service/helloworld-go-00001           ClusterIP      10.100.172.219   <none>                                             80/TCP,443/TCP                                       47s
service/helloworld-go-00001-private   ClusterIP      10.100.7.170     <none>                                             80/TCP,443/TCP,9090/TCP,9091/TCP,8022/TCP,8012/TCP   48s

NAME                                             READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/helloworld-go-00001-deployment   1/1     1            1           48s

NAME                                                 READY   STATUS    RESTARTS   AGE
pod/helloworld-go-00001-deployment-5c44fdc68-njv7n   2/2     Running   0          48s

查看 configuration

# kubectl get configurations -n knative-demo
NAME            LATESTCREATED         LATESTREADY           READY   REASON
helloworld-go   helloworld-go-00001   helloworld-go-00001   True   

查看 revision

# kubectl get revisions -n knative-demo
NAME                  CONFIG NAME     K8S SERVICE NAME   GENERATION   READY   REASON   ACTUAL REPLICAS   DESIRED REPLICAS
helloworld-go-00001   helloworld-go                      1            True             0                 0

查看 kpa

# kubectl get kpa -n knative-demo
NAME                  DESIREDSCALE   ACTUALSCALE   READY   REASON
helloworld-go-00001   0              0             False   NoTraffic

查看 route

# kubectl get rt -n knative-demo
NAME            URL                                               READY   REASON
helloworld-go   http://helloworld-go.knative-demo.svc.wgs.local   True    

查看 ingress 地址

# kubectl --namespace istio-system get service istio-ingressgateway
NAME                   TYPE           CLUSTER-IP       EXTERNAL-IP       PORT(S)                                      AGE
istio-ingressgateway   LoadBalancer   10.100.132.184   192.168.174.249   15021:31063/TCP,80:56051/TCP,443:33148/TCP   40m

查看 istio ingress 路由信息

# istioctl proxy-config all istio-ingressgateway-568ffb9976-lk455 -n istio-system |grep helloworld-go
helloworld-go-00001-private.knative-demo.svc.wgs.local           80        -          outbound      EDS            
helloworld-go-00001-private.knative-demo.svc.wgs.local           443       -          outbound      EDS            
helloworld-go-00001-private.knative-demo.svc.wgs.local           8012      -          outbound      EDS            
helloworld-go-00001-private.knative-demo.svc.wgs.local           8022      -          outbound      EDS            
helloworld-go-00001-private.knative-demo.svc.wgs.local           9090      -          outbound      EDS            
helloworld-go-00001-private.knative-demo.svc.wgs.local           9091      -          outbound      EDS            
helloworld-go-00001.knative-demo.svc.wgs.local                   80        -          outbound      EDS            
helloworld-go-00001.knative-demo.svc.wgs.local                   443       -          outbound      EDS            
helloworld-go.knative-demo.svc.wgs.local                         80        -          outbound      STRICT_DNS     
http.8081     helloworld-go.knative-demo.svc.wgs.local:8081     helloworld-go.knative-demo.svc.wgs.local, helloworld-go.knative-demo.wgs.com + 1 more...     /*                     helloworld-go-ingress.knative-demo
http.8081     helloworld-go.knative-demo.svc.wgs.local:8081     helloworld-go.knative-demo.svc.wgs.local, helloworld-go.knative-demo.wgs.com + 1 more...     /*                     helloworld-go-ingress.knative-demo
http.8080     helloworld-go.knative-demo.svc.wgs.local:80       helloworld-go.knative-demo.svc.wgs.local, helloworld-go.knative-demo.wgs.com + 1 more...     /*                     helloworld-go-ingress.knative-demo
http.8080     helloworld-go.knative-demo.svc.wgs.local:80       helloworld-go.knative-demo.svc.wgs.local, helloworld-go.knative-demo.wgs.com + 1 more...     /*                     helloworld-go-ingress.knative-demo

集群内部访问应用

创建测试 pod

# kubectl run client --image=ikubernetes/admin-box -it --rm --restart=Never --command -n default -- /bin/bash
If you don't see a command prompt, try pressing enter.
root@client /# 

 内部访问应用

# curl http://helloworld-go.knative-demo.svc.wgs.local
Hello Go Sample v1!

集群外部访问应用

设置 DNS

# kubectl patch configmap/config-domain       --namespace knative-serving       --type merge       --patch '{"data":{"wgs.com":""}}'

查看 rt

# kubectl get rt -n knative-demo
NAME            URL                                         READY   REASON
helloworld-go   http://helloworld-go.knative-demo.wgs.com   True    

外部访问应用

# curl -H "Host: helloworld-go.knative-demo.wgs.com" http://192.168.174.249
Hello Go Sample v1!

标签:Serving,demo,helloworld,Knative,wgs,go,local,knative
From: https://www.cnblogs.com/wangguishe/p/17705328.html

相关文章

  • android 实现左右滑动和底部菜单切换Demo
    packagecom.tools.ttt;importstaticandroid.content.ContentValues.TAG;importandroid.content.pm.ActivityInfo;importandroid.content.res.Configuration;importandroid.os.Bundle;importandroid.util.Log;importandroid.view.MenuItem;importcom.googl......
  • 【vue2】 demo1
    练习用的<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>Title</title><scriptsrc="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>......
  • python爬虫简易demo
    以下是一个简单的Python爬虫示例,用于从指定的网页中提取标题和链接:importrequestsfrombs4importBeautifulSoupdefcrawl(url):#发送HTTPGET请求获取网页内容response=requests.get(url)#使用BeautifulSoup解析网页内容soup=BeautifulSoup(r......
  • jfreechart常用设置demo(不断更新)
       今天要用到jfreechart的时候到网上看自己的demo才发现,我原来的demo不知什么时候不小心删掉了!我郁闷!不过还好,在我的备份盘中又找到了一份备份资料。现在再重新更新上来!    背景图片为2006110821482378503.jpg放入d盘。72729572一、柱图demoimportjava.awt.Color;impo......
  • RK3568开发笔记(十一):开发版buildroot固件移植一个ffmpeg播放rtsp的播放器Demo
    前言  目标开发任务还有个功能,就是播放rtsp摄像头,当然为了更好的坐这个个,我们必须支持rtsp播放失败之后重新尝试,比如5s重新尝试打开一次,从而保障联网后重新打开,然后达成这个功能。 Demo   补充  得益于方案上的buildroot已经移植了ffmpeg4.1.3。  ......
  • Java学习一路-Demo01-Java数据类型
    packagecom.chao.base;publicclassDemo01{/*Java数据类型两大类:基本数据类型和引用类型1.基本数据类型共8种:(1)数值类型分为:整数类型(4种):a.byte(字节型),占1个字节,取值范围(-128~127)b.short(短整型),占2个字节,取值范围......
  • Java学习之路-Demo02
    packagecom.chao.base;publicclassDemo02{publicstaticvoidmain(String[]args){//整数拓展:进制二进制0b十进制八进制0十六进制0xinti=10;inti1=010;//八进制0inti2=0x10;//十六进制0x0~9A~F16System......
  • Java学习之路-Demo03-类型转换
    packagecom.chao.base;publicclassDemo03{publicstaticvoidmain(String[]args){inti=128;byteb=(byte)i;//内存溢出doubled=i;//强制转换(类型)变量名高-->低例:int转byte,int转short,int转char等//自动转换......
  • 【微信小程序】【Demo】Picker模糊查询组件
    微信小程序Picker模糊查询组件 pickerSelect.jsComponent({options:{//在组件定义时的选项中启用多slot支持multipleSlots:true},/***组件的属性列表*/properties:{//父组件传递过来的数据列表items:{type:Array,......
  • RK3568开发笔记(十):开发板buildroot固件移植开发的应用Demo,启动全屏显示
    前言  上一篇,移植应用前的通讯接口工作和全屏工作都已经完成了。本篇移植开发的商业应用。<br>交叉编译好应用  (略),参照《RK3568开发笔记(八):开发板烧写buildroot固件(支持hdmi屏),搭建Qt交叉编译开发环境,编译一个Demo,目标板运行Demo测试》<br>解决全屏标题栏占用问题  交叉......