F5|F5 对接 K8S 实现服务发现

F5|F5 对接 K8S 实现服务发现
文章图片

作者 | 高宇航
职位 | F5解决方案顾问
在容器技术发展初期,企业只在开发、测试环境中使用容器。随着容器技术的发展以及企业对于容器技术的理论和实践的掌握逐渐加深,企业开始在生产环境中使用容器,使用规模也越来越大。K8S无疑成为了企业管理容器的首选,作为承载现代应用最重要的基础架构。当应用微服务化后,迁移至K8S,开始考虑服务如何对外暴露,当然原生的暴露方式有很多,随着各种类型的服务逐渐迁移至K8S,使用者开始考虑入口服务能力的问题,例如,性能问题、稳定性问题、非HTTP业务发布问题、七层业务发布能力的问题、安全性问题、高效管理问题等等,随后开始调研企业级入口方案。这篇文章给大家带来的是利用MSDA实现K8S平台的服务发现。为什么要给大家介绍这种方式呢?第一是想给大家多一种选择,第二是因为MSDA具备他自身的特性,比如轻量化、无摩擦及与平台无关化,看完之后你可能对这些特性会有一个初步的理解。MSDA是利用iApp LX构建了一个模版,使用该模版可以创建一个服务的实例,整个创建过程如下:?在F5上创建一个服务的资源池Pool,初始为空;
向K8S的Endpoint查询指定Namespace中指定的Service对应的Pod的IP地址和端口(Endpoint是实现实际服务的端点的集合,当service创建后会创建一个和service同名的Endpoint的集合,当然你需要配置selector,所以上面我就那么说了,但是这并不是最严谨的说法,为了便于理解);将查询到的IP地址和端口添加至创建好的Pool中;每隔一定的周期(可自行定义)查询Endpoint中的变化,将变化自动更新到Pool中;实例销毁,Pool和Member将自动删除;利用AS3创建Virtual Server实现服务发布。MSDA实现K8S服务发现的方式有 webui 和API 两种方式: MSDA通过webui实现服务发现的具体操作步骤如下:?01上传f5-iapplx-msda-k8s rpm包至BIGIP->iApps->Package Management LX->import?
F5|F5 对接 K8S 实现服务发现
文章图片

02上传完RPM包后会生成一个Templetes,iApps->Templates->Templates LX?
F5|F5 对接 K8S 实现服务发现
文章图片

将通用的参数证书、Endpoint地址等替换成自己环境中的参数并保存。
F5|F5 对接 K8S 实现服务发现
文章图片

03创建一个实例在iApps->Application Services->Applications LX?
F5|F5 对接 K8S 实现服务发现
文章图片

选择模版点击Next
F5|F5 对接 K8S 实现服务发现
文章图片

将namespace信息、service name、pool名称等信息填写好,点击Deploy
F5|F5 对接 K8S 实现服务发现
文章图片

完成创建后,将发现的服务自动添加至Pool中
F5|F5 对接 K8S 实现服务发现
文章图片

04删除此实例,需要先将该实例Undeploy,然后再删除实例?
F5|F5 对接 K8S 实现服务发现
文章图片

虽然大家看到webui的整个实例创建过程非常简单,但是绝大多数使用者更倾向于自动化和DevOps的方式来批量创建、销毁实例,所以今天我们重点来说明通过API的方式部署MSDA实现K8S上的服务发现。MSDA通过API实现服务发现的具体操作步骤如下:01?上传f5-iapplx-msda-k8s rpm包至BIGIP->IApps->Package Management LX->import如果你愿意你也可以用API导入。
F5|F5 对接 K8S 实现服务发现
文章图片

02?创建一个服务的实例1?使用Postman创建一个实例
F5|F5 对接 K8S 实现服务发现
文章图片

Post的内容如下,标注释的内容需要修改为你自己定义或者环境的内容

??{?? ??“name”: “msdak8s1”,?? ??“inputProperties”: [?? ??{?? ??“id”: “k8sEndpoint”,?? ??“type”: “STRING”,?? ??“value”: “https://192.168.26.31:6443”, #你自己K8s环境的endpoint地址?? ??"metaData": {?? ??"description": "k8s endpoint",?? ??"displayName": "k8s endpoint",?? ??"isRequired": true?? ??}?? ??},?? ??{?? ??"id": "authenticationCert", #下面的clientCert、key、CA需要修改为你自己环境的?? ??"type": "JSON",?? ??"value": {?? ??"clientCert": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURJVENDQWdtZ0F3SUJBZ0lJS2F0bDlLalpCaVF3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TVRBMU1EZ3dOak0xTlRKYUZ3MHlNekExTVRJd05ERTNOVFJhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnp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y5R0Q2YTB0R2trMzM5S3Q4UjcvUUw5Y0NGbHdEcmhwbwpRTVhSWGtCVFl4ejR4ZUFrRkRrQ0F3RUFBYU5DTUVBd0RnWURWUjBQQVFIL0JBUURBZ0trTUE4R0ExVWRFd0VCCi93UUZNQU1CQWY4d0hRWURWUjBPQkJZRUZERm9FSFU1MEhjNmNYQlpid3dubGZ5M29zYlBNQTBHQ1NxR1NJYjMKRFFFQkN3VUFBNElCQVFCSndVdHpwdGlwYmRWbU0yb0JMZk1vTzFPbzBmbGdUdUQvVFJSWUUraHRLYWM5MWFXMgp0bHVTOTEwVnZrZHMycEV1MS8xSmxDdExJM3ZhZU5yVHY0cndvM2JvbXBRRGlnRzIvbnN3SGdwYzRxZXVNTC9vCkpjUGMrQkgydGw5ZUJsdG9YNFJmaVpsL2JlOXJ4VDY2ZVhTdlZWTVdlZ20zUlJZaDZ1UmZnamZuSmdDZTBoM2cKZVZZcisyOWdscnRDK3ZCeFpHY0w5WkNKVmJPTXgwdXlkMVRmR3V3L1JIWng0NE1OeU1xSmlGSWkwWHpUUU9IVgpPYVNiOHZWc0xDZkMxTnVObVlWMDVUdjQ2RVJMdnlHZzhZZXZyMmc4YUp5MnFrVVk0MGNaZUFoV2dBYWZUZ052CjYrdFluSW4yMjVvek9vWklUWFg1UVkrL3BBcFNpQVF3VzJzNQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg=="?? ??},?? ??"metaData": {?? ??"description": "k8s lient authentication certificate in base64 encoding",?? ??"displayName": "k8s client certificate",?? ??"isRequired": true?? ??}?? ??},?? ??{?? ??"id": "nameSpace",?? ??"type": "STRING",?? ??"value": "test002", #修改为你自己环境中服务所在的namespace?? ??“metaData”: {?? ??“description”: “Namespace in kubernetes”,?? ??“displayName”: “Namespace Name in kubernetes”,?? ??“isRequired”: true?? ??}?? ??},?? ??{?? ??“id”: “serviceName”,?? ??“type”: “STRING”,?? ??“value”: “msda1”, #修改为你对应的Service名称?? ??"metaData": {?? ??"description": "Service name to be exposed",?? ??"displayName": "Service Name in kubernetes",?? ??"isRequired": true?? ??}?? ??},?? ??{?? ??"id": "poolName",?? ??"type": "STRING",?? ??"value": "/Common/Pool1", #你要创建的Pool的名称?? ??“metaData”: {?? ??“description”: “Pool Name to be created”,?? ??“displayName”: “BIG-IP Pool Name”,?? ??“isRequired”: true?? ??}?? ??},?? ??{?? ??“id”: “poolType”,?? ??“type”: “STRING”,?? ??“value”: “round-robin”, #你要选择的负载均衡算法,请在下面list中选择?? ??"metaData": {?? ??"description": "load-balancing-mode",?? ??"displayName": "Load Balancing Mode",?? ??"isRequired": true,?? ??"uiType": "dropdown",?? ??"uiHints": {?? ??"list": {?? ??"dataList": [?? ??"round-robin",?? ??"least-connections-member",?? ??"least-connections-node"?? ??]?? ??}?? ??}?? ??}?? ??},?? ??{?? ??"id": "healthMonitor",?? ??"type": "STRING",?? ??"value": "http", #选择你要的健康检查算法,在下面list中选择?? ??"metaData": {?? ??"description": "Health Monitor",?? ??"displayName": "Health Monitor",?? ??"isRequired": true,?? ??"uiType": "dropdown",?? ??"uiHints": {?? ??"list": {?? ??"dataList": [?? ??"tcp",?? ??"udp",?? ??"http",?? ??"none"?? ??]?? ??}?? ??}?? ??}?? ??}?? ??],?? ??"dataProperties": [?? ??{?? ??"id": "pollInterval",?? ??"type": "NUMBER",?? ??"value": 15, #这里是你需要多久去查询一次?? ??“metaData”: {?? ??“description”: “Interval of polling from BIG-IP to registry, 30s by default.”,?? ??“displayName”: “Polling Invertal”,?? ??“isRequired”: false?? ??}?? ??}?? ??],?? ??“configurationProcessorReference”: {?? ??“link”: “https://localhost/mgmt/shared/iapp/processors/msdak8sConfig”?? ??},?? ??“auditProcessorReference”: {?? ??“link”: “https://localhost/mgmt/shared/iapp/processors/msdak8sEnforceConfiguredAudit”?? ??},?? ??“audit”: {?? ??“intervalSeconds”: 60,?? ??“policy”: “ENFORCE_CONFIGURED”?? ??},?? ??“sourcePackage”: {?? ??“packageName”: “f5-iapplx-msda-k8s-0.0.3-0003.noarch”?? ??},?? ??“configProcessorTimeoutSeconds”: 30,?? ??“statsProcessorTimeoutSeconds”: 15,?? ??“configProcessorAffinity”: {?? ??“processorPolicy”: “LOAD_BALANCED”,?? ??“affinityProcessorReference”: {?? ??“link”: “https://localhost/mgmt/shared/iapp/processors/affinity/load-balanced”?? ??}?? ??},?? ??“state”: “BINDING”, #如果你使用的是默认的模版,这里状态改为BINDING?? ??"generation": 10,?? ??"lastUpdateMicros": 1656552937409259,?? ??"kind": "shared:iapp:blocks:blockstate",?? ??"selfLink": "https://localhost/mgmt/shared/iapp/blocks/b4d1b6ea-30cb-35f9-8704-de9c712d522e"??

2?F5上创建了一个新的Pool里面并没有Member(初始状态)
F5|F5 对接 K8S 实现服务发现
文章图片

3?确认K8S Service和Endpoint状态
F5|F5 对接 K8S 实现服务发现
文章图片

4?观察Pool里面已经自动添加了对应的成员
F5|F5 对接 K8S 实现服务发现
文章图片

5?当pool成员发生变化时,会自动添加或者删除池成员扩展deployment
F5|F5 对接 K8S 实现服务发现
文章图片

池成员自动被添加
F5|F5 对接 K8S 实现服务发现
文章图片

6?使用AS3将业务发布
F5|F5 对接 K8S 实现服务发现
文章图片

【F5|F5 对接 K8S 实现服务发现】Post内容如下:
{?? ??"class": "AS3",?? ??"declaration": {?? ??"class": "ADC",?? ??"schemaVersion": "3.1.0",?? ??"id": "urn:uuid:3da22137-87a0-460a-b185-3592d5a13682",?? ??"label": "Converted Declaration",?? ??"remark": "Generated by Automation Config Converter",?? ??"Common": {?? ??"class": "Tenant",?? ??"Shared": {?? ??"class": "Application",?? ??"template": "shared",?? ??"vs1": {?? ??"layer4": "tcp",?? ??"pool": {?? ??"bigip": "/Common/Pool1"?? ??},?? ??"translateServerAddress": true,?? ??"translateServerPort": true,?? ??"class": "Service_TCP",?? ??"profileTCP": {?? ??"bigip": "/Common/tcp"?? ??},?? ??"virtualAddresses": [?? ??"192.168.26.188"?? ??],?? ??"virtualPort": 80,?? ??"snat": "auto"?? ??}?? ??}?? ??}?? ??}?? ??}??

观察Virtual Server已经创建完成,关联了刚才创建的Pool,此API可以在Pool生成后立即执行,这就是分两段式完成了业务发布。
F5|F5 对接 K8S 实现服务发现
文章图片

03
F5|F5 对接 K8S 实现服务发现
文章图片

Undeploy实例要删除实例前必须先Undeploy实例,Undeploy我们使用PATCH方法,Block后面要加上生成时产生的id
F5|F5 对接 K8S 实现服务发现
文章图片

Post的数据如下,标注释的内容需要修改
“name”: “msdak8s”, “inputProperties”: [ { “id”: “k8sEndpoint”, “type”: “STRING”, “value”: “https://192.168.26.31:6443”, “metaData”: { “description”: “k8s endpoint”, “displayName”: “k8s endpoint”, “isRequired”: true } }, { “id”: “authenticationCert”, “type”: “JSON”, “value”: { “clientCert”: “LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURJVENDQWdtZ0F3SUJBZ0lJS2F0bDlLalpCaVF3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TVRBMU1EZ3dOak0xTlRKYUZ3MHlNekExTVRJd05ERTNOVFJhTURReApGekFWQmdOVkJBb1Rebk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXQ4QlVGdmQ4eDZJRnZZZlEKYW5qTHR3Sjl5eUlPVi9zOUFMakJsSlplaGZidmhnWUtrTUJqMUgwY05Nsy8xQWIrSElQQVVWOThjWXNpeGdBWQoxMHVUTitkK2N1WHUrVDljbDBpdkJ1MkEvYW1CT29UTDg3eWNlYjdZZlBEYUxuME9RVHV4NmJ6WehIZ1RHMW9ICnBlNGI5UWhrNGZlell3clVQQWRtMUNOcnYrbUppZzFjQ29mdkRDQ3Bja0Q3UWF5NmxLNmVHbDVYZjNmQ3R0VGYKY3d5MWNBby9oak53W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YzRxZXVNTC9vCkpjUGMrQkgydGw5ZUJsdG9YNFJmaVpsL2JlOXJ4VDY2ZVhTdlZWTVdlZ20zUlJZaDZ1UmZnamZuSmdDZTBoM2cKZVZZcisyOWdscnRDK3ZceFpHY0w5WkNKVmJPTXgwdXlkMVRmR3V3L1JIWng0NE1OeU1xSmlGSWkwWHpUUU9IVgpPYVNiOHZWc0xDZkMxTnVObVlWMDVUdjQ2RVJMdnlHZzhZZXZyMmc4Yup5MnFrVVk0MGNaZUFoV2dBYWZUZ052CjYrdFluSW4yMjVvek9vWklUWFg1UvkrL3BBcFNpQVF3VzJzNQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==” }, “metaData”: { “description”: “k8s lient authentication certificate in base64 encoding”, “displayName”: “k8s client certificate”, “isRequired”: true } }, { “id”: “nameSpace”, “type”: “STRING”, “value”: “test002”, “metaData”: { “description”: “Namespace in kubernetes”, “displayName”: “Namespace Name in kubernetes”, “isRequired”: true } }, { “id”: “serviceName”, “type”: “STRING”, “value”: “msda1”, “metaData”: { “description”: “Service name to be exposed”, “displayName”: “Service Name in kubernetes”, “isRequired”: true } }, { “id”: “poolName”, “type”: “STRING”, “value”: “/Common/Pool1”, “metaData”: { “description”: “Pool Name to be created”, “displayName”: “BIG-IP Pool Name”, “isRequired”: true } }, { “id”: “poolType”, “type”: “STRING”, “value”: “round-robin”, “metaData”: { “description”: “load-balancing-mode”, “displayName”: “Load Balancing Mode”, “isRequired”: true, “uiType”: “dropdown”, “uiHints”: { “list”: { “dataList”: [ “round-robin”, “least-connections-member”, “least-connections-node” ] } } } }, { “id”: “healthMonitor”, “type”: “STRING”, “value”: “http”, “metaData”: { “description”: “Health Monitor”, “displayName”: “Health Monitor”, “isRequired”: true, “uiType”: “dropdown”, “uiHints”: { “list”: { “dataList”: [ “tcp”, “udp”, “http”, “none” ] } } } } ], “dataProperties”: [ { “id”: “pollInterval”, “type”: “NUMBER”, “value”: 15, “metaData”: { “description”: “Interval of polling from BIG-IP to registry, 30s by default.”, “displayName”: “Polling Invertal”, “isRequired”: false } } ], “configurationProcessorReference”: { “link”: “https://localhost/mgmt/shared/iapp/processors/msdak8sConfig” }, “auditProcessorReference”: { “link”: “https://localhost/mgmt/shared/iapp/processors/msdak8sEnforceConfiguredAudit” }, “audit”: { “intervalSeconds”: 60, “policy”: “ENFORCE_CONFIGURED” }, “sourcePackage”: { “packageName”: “f5-iapplx-msda-k8s-0.0.3-0003.noarch” }, “configProcessorTimeoutSeconds”: 30, “statsProcessorTimeoutSeconds”: 15, “configProcessorAffinity”: { “processorPolicy”: “LOAD_BALANCED”, “affinityProcessorReference”: { “link”: “https://localhost/mgmt/shared/iapp/processors/affinity/load-balanced” } }, “state”: “UNBINDING”, #如果你使用的是默认的模版,请将该处改为UNBINDING "generation": 11, #这里你需要设置为生成实例+1 "lastUpdateMicros": 1656552937409259, "kind": "shared:iapp:blocks:blockstate", "selfLink": "https://localhost/mgmt/shared/iapp/blocks/b4d1b6ea-30cb-35f9-8704-de9c712d522e" }

Undeploy实例后,其实创建的Pool已经被删除了,但是实例并没有被完全删除,你可以直接部署。请使用Undeploy的内容“state”: “UNBINDING”, #将此处改为BINDING"generation": 12, #generation视你当前的操作来确定,如果你写错了,响应会提示你该写几
F5|F5 对接 K8S 实现服务发现
文章图片

04?删除一个实例删除一个实例就比较简单了,我们直接使用delete方法在Block后面加上id即可
F5|F5 对接 K8S 实现服务发现
文章图片

以上是通过MSDA实现K8S环境的服务自动发现的实现过程,如果有了模版,整个过程还是比较简单的,当然全部过程你可以通过web界面或者API的方式实现,但是更多的可能会想看到自动化运维的实现过程,所以我这里着重说明了使用API的方式去实现。如果各位有兴趣自己动手验证,可参考下面的链接以获取相关安装包。免费使用?欢迎使用下载
F5|F5 对接 K8S 实现服务发现
文章图片

免责声明:这些 iAppsLX RPM 软件包并非F5公司官方支持的产品,如有任何问题或反馈,请向 GitHub repo 上提交 issue,或发送电子邮件至 msda@f5.com

    推荐阅读