-
Notifications
You must be signed in to change notification settings - Fork 125
Create 'Service' CRD to register and reference k8s and non-k8s compute resources #67
Conversation
Could you describe the problem you're solving a little bit more? It sounds like you're looking to do virtual host style stuff? Couple other comments:
|
@grampelberg Thanks for taking the time to read through this. Responses inline:
At the moment SMI spec is focused on Kubernetes. I'd like to extend the spec so I can declare a Service Mesh, which spans:
The proposal is to uniquely identify a service running on a given k8s cluster and reference that in the existing SMI CRDs. I think of this as a declarative way to create a new service registry entry.
I picked
Would love to come up with a better name for this CRD, once we have established that this declarative service registry is good for the community. Another idea was
It would have been great to reuse the existing Kubernetes |
Ahhha! This is great. Let's separate these all into separate pieces:
I've been spending a bunch of time thinking about this one recently. There are two pieces to this one:
This is the one I'm probably the weakest on. What problem really needs solving here? If it is service discovery, I'm thinking the classic k8s
As SMI is currently defined as CRDs for k8s, should this one be out of scope? |
@grampelberg I'm so glad to hear that you are thinking about multi-Kubernetes cluster service mesh. I know a bunch of smart people are thinking about it and we'll be able to extend SMI to accommodate for that. I'd like to focus on augmenting SMI to bridge a Kubernetes cluster and a VM in this case - I'd like to flatten them into one service mesh. (I love how @mitchellh calls it a "flat world") Here is another way to look at what I'm trying to solve: The issue filed here is similar: linkerd/linkerd2#2048 Here is an example: # Register a service consisting of a specific cloud vendor's component
# Members of the service (IP addresses) are resolvable by querying the
# particular cloud provider (type) for the given resource (locator)
apiVersion: specs.smi-spec.io/v1alpha1
kind: Service
metadata:
name: baz.mesh
spec:
type: Azure
locator: /resource/subscriptions/e3f0/resourceGroups/mesh-rg/providers/Microsoft.Compute/virtualMachineScaleSets/baz
port: 7654 @grampelberg I tried using the classic k8s Service. I tried to shoehorn the idea of a VM kind: Service
apiVersion: v1
metadata:
name: out-of-cluster-service
spec:
type: ClusterIP
selector:
locator: /resource/subscriptions/e3f0/resourceGroups/mesh-rg/providers/Microsoft.Compute/virtualMachineScaleSets/baz
ports:
- port: 7654 But
So like I said in my first message - it would have been good to reuse k8s Service, but it has limitations. For that reason I propose we create a new CRD to register these out of cluster services.
Agreed - non-Kubernetes service meshes can stay out of scope for now. @nicholasjackson Would love to hear your opinion on the proposal here to provide the |
What's the benefit to having I was thinking something like this: apiVersion: v1
kind: Service
metadata:
name: linkerd-web
namespace: linkerd
spec:
ports:
- name: http
port: 8084
protocol: TCP
targetPort: 8084
- name: admin-http
port: 9994
protocol: TCP
targetPort: 9994
---
apiVersion: v1
kind: Endpoints
metadata:
name: linkerd-web
namespace: linkerd
subsets:
- addresses:
- ip: 192.168.10.10
nodeName: baz
targetRef:
kind: VM
name: baz
namespace: linkerd
ports:
- name: http
port: 8084
protocol: TCP
- name: admin-http
port: 9994
protocol: TCP If we use a pattern like this, apps that aren't part of the mesh will be able to use the service and talk to the VMs. |
- kind: Service | ||
name: foo.mesh | ||
- kind: Service | ||
name: bar.mesh | ||
- kind: Service | ||
name: baz.mesh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you reference this as TrafficSplit as I feel it is a more compelling example for this proposal?
Here's how I would do this: kind: AzureResource
metadata:
name: my-resource-group
namespace: dev
labels:
app: foobar
selector: /resource/subscriptions/e3f0/resourceGroups/mesh-rg/providers/Microsoft.Compute/virtualMachineScaleSets/baz
---
kind: Service
metadata:
name: baz
namespace: dev
spec:
ports:
- name: http
port: 8084
targetPort: 8000
protocol: TCP
selector:
app: foobar There would then be an operator installed on cluster that watches
Open Questions
|
@grampelberg - can the Azure example be merged with the earlier proposal just above it? Right now they look quite different. For e.g. can the Azure resource string be specified as an endpoint? |
@aanandr I'm not sure what your question is. My proposal completely replaces the original. |
``` | ||
|
||
```yaml | ||
# Register a service 'foo.mesh' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@delqn - this has the facility to use different source types (e.g. a Kubernetes Service, DNS name, Azure resource name). But does it allow users to also use these types for the destination? This will allow creation of access policies for applications running in VMs, for e.g.
@@ -73,6 +73,49 @@ sources: | |||
- kind: ServiceAccount | |||
name: prometheus | |||
namespace: default | |||
- kind: Service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the main write-up you mentioned about supporting both ServiceAccount and service. Users can use what they want. Can users use only service name even for single K8S clusters?
@michelleN to follow up |
@draychev - should we close this out for now? |
Closing based on @michelleN & @draychev agreement. |
The intent of this PR is to begin a discussion and propose the addition of a new CRD
Service
.The purpose of the new
service.specs.smi-spec.io
is to register and uniquely identify a component (service) within a service mesh, which spans multiple Kubernetes clusters, and also includes non-Kubernetes compute resources. The component could be anything resolvable to a list of IP addresses and a port:Once a service is registered,
foo.mesh
for instance, it will be referenced byTrafficTarget
(example below),TrafficSplit
, etc.For each
type
ofService
, the service mesh needs to implement a resolver. The new CRD's duty is to provide sufficient and unambiguous information to the service mesh controller, so that it can obtain:The proposal is to augment the existing spec and add the optional ability to reference a
Service
, not replace references toServiceAccount
. For service meshes where a single Kubernetes cluster is involved -kind: ServiceAccount
(illustrated inTrafficTarget
) is sufficient. For multiple Kubernetes clusters forming a mesh however,ServiceAccount
is not specific enough - we need to identify the Kubernetes cluster and ideally also the Kubernetes service within that service account.In the proposal below we deliberately skip the explicit indication of a
ServiceAccount
. Identity discovery for each registered service would be an implementation detail of the particular service mesh. In the case ofService
withtype: Kubernetes
, there could be a 1:1 relationship between Kubernetes Service and ServiceAccount - the service mesh would expect the Service to belong to a ServiceAccount with the same name.Example
In the example below we register 3 unique services:
foo.mesh
, which is resolvable via DNSbar.mesh
, which is a unique name alias of a Kubernetes Service on a uniquely identified Kubernetes cluster and the given name spacebaz.mesh
- referencing a virtual machine scale set within a specific Azure subscription, along with a portThe
TrafficTarget
in this case declares that servicesfoo.mesh
,bar.mesh
, andbaz.mesh
(as well asprometheus
) are allowed to accessservice-a
on port 8080 and at the given URL endpoints.To show a simpler example:
The policy above declares that
bar.mesh
can accessbaz.mesh
.To be more specific - the policy declares that
bar.mesh
, which is the pods forming Kubernetes Servicebar
, in the default namespace on Kubernetes clusteraks-4d61b17c.hcp.westus2.azmk8s.io
, can access servicebaz.mesh
, which is a virtual machine scale set on Azure uniquely identified by/resource/subscriptions/e3f0/resourceGroups/mesh-rg/providers/Microsoft.Compute/virtualMachineScaleSets/baz
.Existing work
I see that @nicholasjackson is already working on something very similar (#60) and would love to combine the 2 efforts.
Note on the code changes
I don't intend on actually merging the specific proposed changes below. Once we have achieved consensus, I will augment this PR (or create a new one) with the actual CRD + documentation and examples. For the time being I am going to temporarily leverage the existing example of
TrafficTarget
for better illustration.Note on naming
Even though it is name-spaced under
specs.smi-spec.io
, the nameService
may be confusing since it conflicts with the existing core Kubernetes resource. Looking forward to suggestions on better naming this CRD.