Kubernetes Federation. Cluster selector annotation

11/13/2017

In the documentation: https://v1-7.docs.kubernetes.io/docs/tasks/administer-federation/cluster/#clusterselector-annotation

It explains that a cluster selector can be configured.

I have a kubernetes federated cluster with two clusters, I have labeled each cluster.

Now I try to create a deployment and deploy it through the federation pane but I'm not able to use the cluster selector feature

{
        "kind": "Deployment",
        "apiVersion": "extensions/v1beta1",
        "metadata": {
                "name": "nginx2",
                "annotations":{
                "federation.alpha.kubernetes.io/cluster-selector": [{"key": "target", "operator":"In", "values": ["local"]}]
                }
        },
        "spec": {

Error: Deployment in version "v1beta1" cannot be handled as a Deployment: [pos 133]: json: expect char '"' but got char '['

With a deploy like this the create works but the selector does not apply.

{
        "kind": "Deployment",
        "apiVersion": "extensions/v1beta1",
        "metadata": {
                "name": "nginx2",
                "annotations":{
                "federation.alpha.kubernetes.io/cluster-selector": "[{\"key\": \"target\", \"operator\":\"In\", \"values\": [\"local\"]}]"
                }
        },
        "spec": {

How can I use the cluster selector feature?

Thank you.

-- Jxadro
kubernetes

1 Answer

5/29/2018

The documentation has been improved an now there is an example:

metadata: annotations: federation.alpha.kubernetes.io/cluster-selector: '[{"key": "pci", "operator": "In", "values": ["true"]}, {"key": "environment", "operator": "NotIn", "values": ["test"]}]'

https://kubernetes.io/docs/tasks/administer-federation/cluster/#clusterselector-annotation

-- Jxadro
Source: StackOverflow