• fn project k8s 集成


    具体部署还是比较简单的,以下为官方参考,只是有一个service type 为 loadBlancer 实际使用需要修改为NodePort 

    Prerequisite 1: working Kubernetes cluster (v1.7+), and a locally configured kubectl.

     Quickstart

       Steps

    1. Deploy Fn to the Kubernetes cluster:
    $ cd docs/operating/
    $ kubectl create -f fn-service.yaml
    1. Once the Pods have started, check the service for the load balanacer IP:
    $ kubectl get svc --watch
    NAME                                CLUSTER-IP      EXTERNAL-IP     PORT(S)                                                       AGE
    fn-mysql-master                     10.96.57.185    <none>          3306/TCP                                                      10m
    fn-redis-master                     10.96.127.51    <none>          6379/TCP                                                      10m
    fn-service                          10.96.245.95    <pending>       8080:30768/TCP,80:31921/TCP                                   10m
    kubernetes                          10.96.0.1       <none>          443/TCP                                                       15d

    Note that fn-service is initially pending on allocating an external IP. The kubectl get svc --watch command will update this once an IP has been assigned.

    1. Test the cluster:

    If you are using a Kubernetes setup that can expose a public load balancer, run:

    $ export FUNCTIONS=$(kubectl get -o json svc fn-service | jq -r '.status.loadBalancer.ingress[0].ip'):8080

    If you are using a Kubernetes setup like minikube, run

    $ echo $(minikube ip):$(kubectl get svc fn-service -o json | jq -r '.spec.ports[0].nodePort')
    192.168.99.100:30966
    $ export API_URL=http://192.168.99.100:30966

    Now, test by creating a function via curl:

    $ curl -H "Content-Type: application/json" -X POST -d '{ "app": { "name":"myapp" } }' http://$API_URL/v1/apps
    {"message":"App successfully created","app":{"name":"myapp","config":null}}
    
    $ curl -H "Content-Type: application/json" -X POST -d '{ "route": { "type": "sync", "path":"/hello-sync", "image":"fnproject/hello" } }' http://$API_URL/v1/apps/myapp/routes
    {"message":"Route successfully created","route":{"app_name":"myapp","path":"/hello-sync","image":"fnproject/hello","memory":128,"headers":{},"type":"sync","format":"default","timeout":30,"idle_timeout":30,"config":{}}}
    
    $ curl -H "Content-Type: application/json" -X POST -d '{ "name":"Johnny" }' http://$API_URL/r/myapp/hello-sync
    Hello Johnny!

    You can also use the Fn CLI:

    $ export API_URL=http://192.168.99.100:30966
    $ fn apps list
    myapp
    $ fn routes list myapp
    path            image           endpoint
    /hello-sync     fnproject/hello 192.168.99.100:30966/r/myapp/hello-sync
     

    <wiz_tmp_tag id="wiz-table-range-border" contenteditable="false" style="display: none;">

  • 相关阅读:
    (九)SpringBoot之错误处理
    (九)SpringBoot之使用jsp
    (八)SpringBoot之freeMarker基本使用
    (七)freemarker的基本语法及入门基础
    (六)Spring Boot之日志配置-logback和log4j2
    (五)Spring Boot之@RestController注解和ConfigurationProperties配置多个属性
    (四)Spring Boot之配置文件-多环境配置
    HashPayloadPcapReader
    Wireshark理解TCP乱序重组和HTTP解析渲染
    Centos定时启动和清除任务
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/7628945.html
Copyright © 2020-2023  润新知