首页 > 其他分享 >knative serving 域名映射

knative serving 域名映射

时间:2023-10-07 17:14:24浏览次数:36  
标签:serving 映射 demo helloworld knative wgs go com

创建应用

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

查看资源

# kubectl get svc,rt,vs -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                                               116s
service/helloworld-go-00001           ClusterIP      10.100.191.179   <none>                                             80/TCP,443/TCP                                       119s
service/helloworld-go-00001-private   ClusterIP      10.100.86.43     <none>                                             80/TCP,443/TCP,9090/TCP,9091/TCP,8022/TCP,8012/TCP   119s

NAME                                      URL                                               READY   REASON
route.serving.knative.dev/helloworld-go   http://helloworld-go.knative-demo.svc.wgs.local   True    

NAME                                                       GATEWAYS                                    HOSTS                                                                                                        AGE
virtualservice.networking.istio.io/helloworld-go-ingress   ["knative-serving/knative-local-gateway"]   ["helloworld-go.knative-demo","helloworld-go.knative-demo.svc","helloworld-go.knative-demo.svc.wgs.local"]   116s
virtualservice.networking.istio.io/helloworld-go-mesh      ["mesh"]                                    ["helloworld-go.knative-demo","helloworld-go.knative-demo.svc","helloworld-go.knative-demo.svc.wgs.local"]   116s

ClusterDomainClaim

要创建 DomainMapping,您必须首先拥有 ClusterDomainClaim。此 ClusterDomainClaim 将域名委托给要在其中创建 DomainMapping 的名称空间,这使得该名称空间中的 DomainMapping 能够使用该域名。

手动创建 ClusterDomainClaim

cdc.yaml

apiVersion: networking.internal.knative.dev/v1alpha1
kind: ClusterDomainClaim
metadata:
  name: helloworld.wgs.com
spec:
  namespace: knative-demo

创建 cdc 资源

# kubectl apply -f cdc.yaml
clusterdomainclaim.networking.internal.knative.dev/helloworld.wgs.com created

查看 cdc 资源

# kubectl get cdc -n knative-demo
NAME                 AGE
helloworld.wgs.com   70s

自动创建 ClusterDomainClaims

# kubectl patch configmap config-network -n knative-serving -p '{"data":{"autocreate-cluster-domain-claims":"true"}}'
configmap/config-network patched

DomainMapping

dm.yaml

apiVersion: serving.knative.dev/v1beta1
kind: DomainMapping
metadata:
  name: helloworld.wgs.com
  namespace: knative-demo
spec:
  ref:
    name: helloworld-go
    kind: Service
    apiVersion: serving.knative.dev/v1
    namespace: knative-demo

---
# 自动创建cdc
apiVersion: serving.knative.dev/v1beta1
kind: DomainMapping
metadata:
  name: helloworld-go.wgs.com
  namespace: knative-demo
spec:
  ref:
    name: helloworld-go
    kind: route
    apiVersion: serving.knative.dev/v1
    namespace: knative-demo

创建 dm

# kubectl apply -f dm.yaml
domainmapping.serving.knative.dev/helloworld.wgs.com created
domainmapping.serving.knative.dev/helloworld-go.wgs.com created

查看 dm

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

查看 vs

# kubectl get vs -n knative-demo
NAME                            GATEWAYS                                      HOSTS                                                                                                        AGE
helloworld-go-ingress           ["knative-serving/knative-local-gateway"]     ["helloworld-go.knative-demo","helloworld-go.knative-demo.svc","helloworld-go.knative-demo.svc.wgs.local"]   34m
helloworld-go-mesh              ["mesh"]                                      ["helloworld-go.knative-demo","helloworld-go.knative-demo.svc","helloworld-go.knative-demo.svc.wgs.local"]   34m
helloworld-go.wgs.com-ingress   ["knative-serving/knative-ingress-gateway"]   ["helloworld-go.wgs.com"]                                                                                    90s
helloworld.wgs.com-ingress      ["knative-serving/knative-ingress-gateway"]   ["helloworld.wgs.com"]                                                                                       90s

访问测试

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

参考文档

https://knative.dev/docs/serving/services/custom-domains/

标签:serving,映射,demo,helloworld,knative,wgs,go,com
From: https://www.cnblogs.com/wangguishe/p/17746371.html

相关文章

  • huoji69键盘的映射值
    先用xev程序获取按键的keycode的值,剩下的就是自己修改即可。修改.Xmodmap文件,内容为:1!keycode9=asciitildegrave2keycode9=asciitildegrave3!keycode66=Escape4keycode118=F12Insert5keycode119=F11Prior6keycode112=F10Next7keycode117=Delet......
  • Serverless平台knative第八章流量管理
    准备环境创建一个服务两个版本[root@ip-172-17-11-227~]#catblue.yamlapiVersion:serving.knative.dev/v1kind:Servicemetadata:name:demoappspec:template:metadata:name:demoapp-01spec:containers:#-image:gcr.io/knative......
  • Serverless平台knative第六章配置最大并发数及更新操作讲解
    并发数配置apiVersion:serving.knative.dev/v1kind:Servicemetadata:name:hellospec:template:metadata:name:hello-world-002spec:containerConcurrency:10#单个pod允许的最大并发数,超过将扩容containers:#-image:gcr......
  • [架构之路-25]:目标系统 - 系统软件 - bootloader uboot内存映射与启动流程
    原文:https://blog.csdn.net/HiWangWenBing/article/details/127062057目录第1章uboot概述1.1概述1.2内存映射(案例)1.3uboot在嵌入式系统启动中的位置第2章uboot启动流程(源码分析)2.1入口函数:_start2.3执行流程(文字描述)2.4初始化过程第3章uboot如何加载内核3.1v......
  • knative所有服务域名及单域名配置方法
    为所有服务配置域名kubectleditconfigmapconfig-domain-nknative-servingapiVersion:v1data:yht.com:""#写你要配置的域名查看域名在创建完应用之后会自动创建域名默认域名格式为:kservice名字+命名空间+二级域名。可修改,下面会给出教程[root@ip-172-17-11......
  • Serverless平台knative第三章部署
    社区版部署环境准备 事先准备Kubernetes集群用于部署knative 选定isitio用来路由和治理流量需要部署的Knative组件 Serving Eventing Kn(KnativeCLI)环境要求 单节点的Kubernetes集群,需要至少有6个CPU核心,6G内存和30G磁盘空间 多节点的Kubernetes集群,每个......
  • Serverless平台knative第四章资源创建
    应用创建  创建和使用KnativeService资源方式有两种:    knservice<sub_command>      资源配置文件      群组:serving.knative.dev/v1       template <Object>用于创建或更新configuation,任何更新,都将创建新的Revision......
  • 映射和序列化
    映射数据库映射(ORM):将数据库表和对象模型之间进行映射,方便开发人员进行对象操作和数据库访问。优点是可以简化数据库操作、提高开发效率,缺点是对于复杂查询和性能要求较高的场景可能会有性能问题。适用于大部分需要与数据库打交道的应用场景。关系映射:将关系型数据库中的表和......
  • Symchk.exe是微软提供的一个命令行工具,用于下载符号文件以帮助调试问题。符号文件包含
    Symchk.exe是微软提供的一个命令行工具,用于下载符号文件以帮助调试问题。符号文件包含用于将二进制文件映射回源代码的关键信息,可帮助开发人员在调试期间确定问题的根本原因。使用Symchk.exe,您可以指定要下载符号文件的二进制文件,该工具会查找相关的PDB文件并将其下载到本地计算......
  • springboot web开发静态资源的映射规则
    前言我们之间介绍过SpringBoot自动配置的原理,基本上是如下:xxxxAutoConfiguration:帮我们给容器中自动配置组件;xxxxProperties:配置类来封装配置文件的内容;web开发中都在org.springframework.boot.autoconfigure.web包下今天看的静态资源映射规则都在org.springframework.boot.aut......