• 创建流量入口或者说添加路由规则/配置插件


    暴露出一个微服务

    echo " apiVersion: extensions/v1beta1 kind: Ingress metadata: name: demo spec: rules: - http: paths: - path: /foo backend: serviceName: httpbin servicePort: 80 - path: /bar backend: serviceName: echo servicePort: 80 " | kubectl apply -f - ingress.extensions/demo created

    在k8s中创建插件资源

     echo '
    apiVersion: configuration.konghq.com/v1
    kind: KongPlugin
    metadata:
      name: add-response-header
    config:
      add:
        headers:
        - "demo: injected-by-kong"
    plugin: response-transformer
    ' | kubectl apply -f -
    kongplugin.configuration.konghq.com/add-response-header created

    关联插件资源和入口资源----把插件应用到路由上
    kubectl patch ingress demo -p '{"metadata":{"annotations":{"plugins.konghq.com":"add-response-header"}}}' ingress.extensions/demo patched

    echo "
    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
      name: demo
      annotations:
        plugins.konghq.com: httpbin-auth
    spec:
      rules:
      - http:
          paths:
          - path: /foo
            backend:
              serviceName: httpbin
              servicePort: 80
    " | kubectl apply -f -


    $ echo "apiVersion: configuration.konghq.com/v1
    kind: KongPlugin
    metadata:
      name: httpbin-auth
    plugin: key-auth
    " | kubectl apply -f -
    
    kongplugin.configuration.konghq.com/httpbin-auth created


      关联插件到服务
    kind: Service
    apiVersion: v1
    metadata:
    labels:
    app: fktaxctl-service
    name: fktaxctl-service
    namespace: chaolai
    annotations:
    plugins.konghq.com: add-response-header #应用插件到服务
    spec:
    type: NodePort
    ports:
    - port: 80
    targetPort: 80
    nodePort: 29999
    selector:
    app: fktaxctl
     



  • 相关阅读:
    BigDecimal精确到几位以及四舍五入
    IDEA配置
    IDEA配置
    IntelliJ IDEA 2018.3.3配置 Tomcat 9,控制台出现中文乱码 “淇℃伅”
    JSP九大内置对象详解
    面试题
    配置编码格式
    SpringAop注解(增强)异常
    springmvc异常
    android保持Session会话
  • 原文地址:https://www.cnblogs.com/justart/p/12433114.html
Copyright © 2020-2023  润新知