Add a loadbalancer CRD

This commit adds CRD to Kuryr that contains informations about
service's annotations and endpoints' annotations, also it is
ensured that CRD is created on the cluster when using devstack.

Partially-Implements: blueprint move-svc-annotations-to-crds

Change-Id: I4088ad09efe96b2d395fb892750adcb39abee3a4
This commit is contained in:
sarka_scavnicka 2019-09-25 14:10:17 +00:00 committed by Sarka Scavnicka
parent 61e2bdcdeb
commit 48f2d2838b
5 changed files with 200 additions and 1 deletions

View File

@ -448,6 +448,7 @@ rules:
resources:
- kuryrnets
- kuryrnetpolicies
- kuryrloadbalancers
- apiGroups: ["networking.k8s.io"]
resources:
- networkpolicies

View File

@ -1165,6 +1165,7 @@ if [[ "$1" == "stack" && "$2" == "extra" ]]; then
if is_service_enabled kuryr-kubernetes; then
/usr/local/bin/kubectl apply -f ${KURYR_HOME}/kubernetes_crds/kuryrnet.yaml
/usr/local/bin/kubectl apply -f ${KURYR_HOME}/kubernetes_crds/kuryrnetpolicy.yaml
/usr/local/bin/kubectl apply -f ${KURYR_HOME}/kubernetes_crds/kuryrloadbalancer.yaml
if [ "$KURYR_K8S_CONTAINERIZED_DEPLOYMENT" == "True" ]; then
generate_containerized_kuryr_resources
fi

View File

@ -0,0 +1,193 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: kuryrloadbalancers.openstack.org
spec:
group: openstack.org
version: v1
scope: Namespaced
names:
plural: kuryrloadbalancers
singular: kuryrloadbalancer
kind: KuryrLoadBalancer
shortNames:
- klb
additionalPrinterColumns:
- name: PROJECT-ID
type: string
description: The ID of the PROJECT associated to the loadbalancer
JSONPath: .spec.project_id
- name: Age
type: date
JSONPath: .metadata.creationTimestamp
validation:
openAPIV3Schema:
properties:
spec:
type: object
required:
- ip
- ports
- project_id
- security_groups_ids
- subnet_id
- type
properties:
ip:
type: string
lb_ip:
type: string
ports:
type: array
items:
type: object
required:
- name
- port
- protocol
- targetPort
properties:
name:
type: string
port:
type: integer
protocol:
type: string
targetPort:
type: string
project_id:
type: string
security_groups_ids:
type: array
items:
type: string
subnet_id:
type: string
type:
type: string
status:
type: object
required:
- listeners
- loadbalancer
- members
- pools
properties:
listeners:
type: array
items:
type: object
required:
- id
- loadbalancer_id
- name
- port
- project_id
- protocol
properties:
id:
type: string
loadbalancer_id:
type: string
name:
type: string
port:
type: integer
project_id:
type: string
protocol:
type: string
loadbalancer:
type: object
required:
- id
- ip
- name
- port_id
- project_id
- provider
- security_groups
- subnet_id
properties:
id:
type: string
ip:
type: string
name:
type: string
port_id:
type: string
project_id:
type: string
provider:
type: string
security_groups:
type: array
items:
type: string
subnet_id:
type: string
members:
type: array
items:
type: object
required:
- id
- ip
- name
- pool_id
- port
- project_id
- subnet_id
properties:
id:
type: string
ip:
type: string
name:
type: string
pool_id:
type: string
port:
type: integer
project_id:
type: string
subnet_id:
type: string
pools:
type: array
items:
type: object
required:
- id
- listener_id
- loadbalancer_id
- name
- project_id
- protocol
properties:
id:
type: string
listener_id:
type: string
loadbalancer_id:
type: string
name:
type: string
project_id:
type: string
protocol:
type: string
service_pub_ip_info:
type: object
required:
- ip_id
- ip_addr
- alloc_method
properties:
ip_id:
type: string
ip_addr:
type: string
alloc_method:
type: string

View File

@ -19,6 +19,7 @@ K8S_API_CRD = '/apis/openstack.org/v1'
K8S_API_CRD_NAMESPACES = K8S_API_CRD + '/namespaces'
K8S_API_CRD_KURYRNETS = K8S_API_CRD + '/kuryrnets'
K8S_API_CRD_KURYRNETPOLICIES = K8S_API_CRD + '/kuryrnetpolicies'
K8S_API_CRD_KURYRLOADBALANCERS = K8S_API_CRD + '/kuryrloadbalancers'
K8S_API_POLICIES = '/apis/networking.k8s.io/v1/networkpolicies'
K8S_API_NPWG_CRD = '/apis/k8s.cni.cncf.io/v1'
@ -30,6 +31,7 @@ K8S_OBJ_ENDPOINTS = 'Endpoints'
K8S_OBJ_POLICY = 'NetworkPolicy'
K8S_OBJ_KURYRNET = 'KuryrNet'
K8S_OBJ_KURYRNETPOLICY = 'KuryrNetPolicy'
K8S_OBJ_KURYRLOADBALANCER = 'KuryrLoadBalancer'
K8S_POD_STATUS_PENDING = 'Pending'

View File

@ -149,7 +149,9 @@ class TestUtils(test_base.TestCase):
def test__has_kuryr_crd_error(self):
crds = [k_const.K8S_API_CRD_KURYRNETS,
k_const.K8S_API_CRD_KURYRNETPOLICIES]
k_const.K8S_API_CRD_KURYRNETPOLICIES,
k_const.K8S_API_CRD_KURYRLOADBALANCERS]
for crd_url in crds:
kubernetes = self.useFixture(k_fix.MockK8sClient()).client
kubernetes.get.side_effect = k_exc.K8sClientException