registry: service add clusterIP, nodePort, loadBalancer support (#8291)

* registry: service add clusterIP, nodePort, loadBalancer support

* modify camelcase name to underscore

* Add registry service type compatibility check
pull/8309/head
zhengtianbao 2021-12-15 02:18:19 -06:00 committed by GitHub
parent 4daa824b3c
commit aa9b8453a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 0 deletions

View File

@ -5,6 +5,18 @@ registry_storage_access_mode: "ReadWriteOnce"
registry_disk_size: "10Gi" registry_disk_size: "10Gi"
registry_port: 5000 registry_port: 5000
registry_replica_count: 1 registry_replica_count: 1
# type of service: ClusterIP, LoadBalancer or NodePort
registry_service_type: "ClusterIP"
# you can specify your cluster IP address when registry_service_type is ClusterIP
registry_service_cluster_ip: ""
# you can specify your cloud provider assigned loadBalancerIP when registry_service_type is LoadBalancer
registry_service_loadbalancer_ip: ""
# annotations for managing Cloud Load Balancers
registry_service_annotations: {}
# you can specify the node port when registry_service_type is NodePort
registry_service_nodeport: ""
# name of kubernetes secret for registry TLS certs # name of kubernetes secret for registry TLS certs
registry_tls_secret: "" registry_tls_secret: ""

View File

@ -1,4 +1,29 @@
--- ---
- name: Registry | check registry_service_type value
fail:
msg: "registry_service_type can only be 'ClusterIP', 'LoadBalancer' or 'NodePort'"
when: registry_service_type not in ['ClusterIP', 'LoadBalancer', 'NodePort']
- name: Registry | Stop if registry_service_cluster_ip is defined when registry_service_type is not 'ClusterIP'
fail:
msg: "registry_service_cluster_ip support only compatible with ClusterIP."
when:
- registry_service_cluster_ip is defined and registry_service_cluster_ip != ""
- registry_service_type != "ClusterIP"
- name: Registry | Stop if registry_service_loadbalancer_ip is defined when registry_service_type is not 'LoadBalancer'
fail:
msg: "registry_service_loadbalancer_ip support only compatible with LoadBalancer."
when:
- registry_service_loadbalancer_ip is defined and registry_service_loadbalancer_ip != ""
- registry_service_type != "LoadBalancer"
- name: Registry | Stop if registry_service_nodeport is defined when registry_service_type is not 'NodePort'
fail:
msg: "registry_service_nodeport support only compatible with NodePort."
when:
- registry_service_nodeport is defined and registry_service_nodeport != ""
- registry_service_type != "NodePort"
- name: Registry | Create addon dir - name: Registry | Create addon dir
file: file:

View File

@ -8,10 +8,25 @@ metadata:
k8s-app: registry k8s-app: registry
addonmanager.kubernetes.io/mode: Reconcile addonmanager.kubernetes.io/mode: Reconcile
kubernetes.io/name: "KubeRegistry" kubernetes.io/name: "KubeRegistry"
{% if registry_service_annotations %}
annotations:
{{ registry_service_annotations | to_nice_yaml(indent=2, width=1337) | indent(width=4) }}
{% endif %}
spec: spec:
selector: selector:
k8s-app: registry k8s-app: registry
type: {{ registry_service_type }}
{% if registry_service_type == "ClusterIP" and registry_service_cluster_ip != "" %}
clusterIP: {{ registry_service_cluster_ip }}
{% endif %}
{% if registry_service_type == "LoadBalancer" and registry_service_loadbalancer_ip != "" %}
loadBalancerIP: {{ registry_service_loadbalancer_ip }}
{% endif %}
ports: ports:
- name: registry - name: registry
port: {{ registry_port }} port: {{ registry_port }}
protocol: TCP protocol: TCP
targetPort: {{ registry_port }}
{% if registry_service_type == "NodePort" and registry_service_nodeport != "" %}
nodePort: {{ registry_service_nodeport }}
{% endif %}