{"id":13928750,"url":"https://github.com/squat/service-reflector","last_synced_at":"2025-03-22T19:33:53.435Z","repository":{"id":73957125,"uuid":"198856723","full_name":"squat/service-reflector","owner":"squat","description":"Service-Reflector mirrors Kubernetes Services so that Pods in one cluster can natively access Services in another","archived":false,"fork":false,"pushed_at":"2020-01-09T14:55:23.000Z","size":5659,"stargazers_count":23,"open_issues_count":2,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-18T14:06:06.021Z","etag":null,"topics":["federation","kubernetes","multi-cluster","networking","service-reflector"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/squat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-25T15:26:48.000Z","updated_at":"2025-02-20T14:41:45.000Z","dependencies_parsed_at":"2023-03-13T20:17:28.867Z","dependency_job_id":null,"html_url":"https://github.com/squat/service-reflector","commit_stats":{"total_commits":18,"total_committers":1,"mean_commits":18.0,"dds":0.0,"last_synced_commit":"2f837b7686a16e79196ad574ccbcc9c92bce103d"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squat%2Fservice-reflector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squat%2Fservice-reflector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squat%2Fservice-reflector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squat%2Fservice-reflector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/squat","download_url":"https://codeload.github.com/squat/service-reflector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245013740,"owners_count":20547175,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["federation","kubernetes","multi-cluster","networking","service-reflector"],"created_at":"2024-08-07T18:01:37.038Z","updated_at":"2025-03-22T19:33:51.840Z","avatar_url":"https://github.com/squat.png","language":"Go","funding_links":[],"categories":["kubernetes"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"./service-reflector.svg\" width=\"200\"\u003e\u003c/p\u003e\n\n# Service-Reflector\n\nService-Reflector mirrors Kubernetes Services so that Pods running in one cluster can natively access Services from another cluster.\n\n[![Build Status](https://travis-ci.org/squat/service-reflector.svg?branch=master)](https://travis-ci.org/squat/service-reflector)\n[![Go Report Card](https://goreportcard.com/badge/github.com/squat/service-reflector)](https://goreportcard.com/report/github.com/squat/service-reflector)\n\n## Overview\n\nA key use for multi-cluster Kubernetes is to allow Pods and Services in one cluster to access those running in another cluster.\nHowever, a Pod in cluster A has no Kubernetes-native way of discovering a Service in cluster B or determining its endpoints; instead it must be pointed explicitly at the Service's ClusterIP.\nOne solution to this issue is for an administrator to create a Service in cluster A to mirror the one in cluster B with Endpoints that point at the Service’s Pods.\nService-Reflector automates the mirroring of selected Services from one cluster to another to simplify running multi-cluster Kubernetes.\n\n## How it works\n\nService-Reflector is comprised of two components: a Reflector and an Emitter.\nBoth components are run by default, though either can be run independently or disabled, via the `--reflector` and `--emitter` flags.\n\n### Reflector\n\nThe Reflector is a controller that watches source APIs for Services to reflect and creates mirror Services and Endpoints in the host cluster.\nOne Reflector can watch many sources for Services, allowing a cluster to access Services from many different clusters.\nThe source APIs can be any Kubernetes-style API that allows listing and watching Services and Endpoints, for example:\n* a Kubernetes apiserver, specified with the `--reflector.source-kubeconfig` flag; or\n* an Emitter, specified with the `--reflector.source-api` flag.\n\n### Emitter\n\nIn order allow a Reflector in cluster A to find Services in cluster B, we must point the Reflector at a source API, namely cluster B's Kubernetes apiserver.\nDoing so requires configuring the Reflector with a Kubeconfig or ServiceAccount token from cluster B.\nTo simplify deployment, Service-Reflector provides an Emitter, a Kubernetes-style apiserver that implements only the list and watch verbs for Services and Endpoints.\nThe only details a Reflector needs to access an Emitter's API is the Emitter's URL.\nFurthermore, the Emitter allows an administrator to specify a selector to limit which Services are exposed to the Reflector; this is done via the `--emitter.selector` flag.\n\n## Installing on Kubernetes\n\n### Step 1: connect Kubernetes clusters\n\nStart by connecting two or more Kubernetes clusters with the desired multi-cluster solution, e.g. [Kilo](https://github.com/squat/kilo).\nThe Service CIDR and Pod CIDR of each cluster must be routable from the others.\n\n### Step 2: install Service-Reflector!\n\nService-Reflector can be installed on any Kubernetes cluster by deploying a Deployment:\n\n```shell\nkubectl apply -f https://raw.githubusercontent.com/squat/service-reflector/master/manifests/service-reflector.yaml\n```\n\n### Step 3: specify source APIs\n\nIn order for the Reflector to find Services to mirror, it must be configured with a source API.\nThe following snippet could be used to configure Service-Reflectors in two clusters:\n\n```shell\n# Register the emitter in cluster1 as a source of the reflector in cluster2.\ncat \u003c\u003cEOF | kubectl --kubeconfig $KUBECONFIG2 apply -f -\napiVersion: v1\nkind: ConfigMap\nmetadata:\n  name: service-reflector\ndata:\n  source-api: http://$(kubectl --kubeconfig $KUBECONFIG1 get service service-reflector -o jsonpath='{.spec.clusterIP}'):8080\nEOF\n# Restart the reflector.\nkubectl --kubeconfig $KUBECONFIG2 delete pod --selector app.kubernetes.io/name=service-reflector\n# Register the emitter in cluster2 as a source of the reflector in cluster1.\ncat \u003c\u003cEOF | kubectl --kubeconfig $KUBECONFIG1 apply -f -\napiVersion: v1\nkind: ConfigMap\nmetadata:\n  name: service-reflector\ndata:\n  source-api: http://$(kubectl --kubeconfig $KUBECONFIG2 get service service-reflector -o jsonpath='{.spec.clusterIP}'):8080\nEOF\n# Restart the reflector.\nkubectl --kubeconfig $KUBECONFIG1 delete pod --selector app.kubernetes.io/name=service-reflector\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquat%2Fservice-reflector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsquat%2Fservice-reflector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquat%2Fservice-reflector/lists"}