OpenShift服务的外部IP分配

OpenShift服务的外部IP分配,openshift,kubernetes,openshift-origin,Openshift,Kubernetes,Openshift Origin,对openshift\u master\u external\u ip\u network\u CIDR有点困惑。当服务公开时,我仍然没有获得外部IP分配 显示服务: [root@node237 origin]# oc get svc NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE cakephp-mysql-example 10.100.127.43 <none> 8

对openshift\u master\u external\u ip\u network\u CIDR有点困惑。当服务公开时,我仍然没有获得外部IP分配

显示服务:

[root@node237 origin]# oc get svc
NAME                    CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
cakephp-mysql-example   10.100.127.43    <none>        8080/TCP   10m
mysql                   10.100.233.247   <none>        3306/TCP   10m
我的ansible hosts文件如下所示:

# Create an OSEv3 group that contains the master, nodes, etcd, and lb groups.
# The lb group lets Ansible configure HAProxy as the load balancing solution.
# Comment lb out if your load balancer is pre-configured.
[OSEv3:children]
masters
nodes
etcd
lb

# Set variables common for all OSEv3 hosts
[OSEv3:vars]
ansible_ssh_user=root
deployment_type=openshift-enterprise
openshift_router_selector='region=infra'
openshift_registry_selector='region=infra'
use_fluentd=true
debug_level=2
#openshift_release=v3.5
# Install the openshift examples
#openshift_install_examples=true

# Uncomment the following to enable htpasswd authentication; defaults to
# DenyAllPasswordIdentityProvider.
#openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider', 'filename': '/etc/origin/master/htpasswd'}]
# MS AD LDAP Integration
openshift_master_identity_providers=[{ 'name': 'Active_Directory_AELAB', 'challenge': 'true', 'login': 'true', 'kind': 'LDAPPasswordIdentityProvider', 'attributes': { 'id': ['dn'], 'email': ['mail'], 'name': ['cn'], 'preferredUsername': ['uid'] }, 'bindDN': 'cn=srvcKeyStone,ou=Users,ou=Global Info Tech Division,ou=BNYM,dc=aelab,dc=localnet,dc=net', 'bindPassword': 'KeySt0ne1!', 'insecure': 'true', 'url': 'ldap://wsomtapae68.aelab.localnet.net:389/dc=aelab,dc=localnet,dc=net?sAMAccountName' }]

# Defining htpasswd users
openshift_master_htpasswd_file=/opt/openshift/htpasswd

# Native high availbility cluster method with optional load balancer.
# If no lb group is defined installer assumes that a load balancer has
# been preconfigured. For installation the value of
# openshift_master_cluster_hostname must resolve to the load balancer
# or to one or all of the masters defined in the inventory if no load
# balancer is present.
openshift_master_cluster_method=native
openshift_master_cluster_hostname=master.openshift-cluster.localnet.net
openshift_master_cluster_public_hostname=master.openshift-cluster.localnet.net

# apply updated node defaults
# Commenting out 'pods-per-core' variable. Getting error while this value is in place:
#
#[root@node261 xbblrfv]# docker logs df
#Invalid NodeConfig /etc/origin/node/node-config.yaml
#  flag: Invalid value: "pods-per-core": is not a valid flag
#openshift_node_kubelet_args={'pods-per-core': ['10'], 'max-pods': ['250'], 'image-gc-high-threshold': ['90'], 'image-gc-low-threshold': ['80']}
openshift_node_kubelet_args={'max-pods': ['40'], 'image-gc-high-threshold': ['90'], 'image-gc-low-threshold': ['80']}

# override the default controller lease ttl
#osm_controller_lease_ttl=30

# enable ntp on masters to ensure proper failover
openshift_clock_enabled=true

# Configure SDN cluster network and kubernetes service CIDR blocks. These
# network blocks should be private and should not conflict with network blocks
# in your infrastructure that pods may require access to. Can not be changed
# after deployment.

osm_cluster_network_cidr=10.128.0.0/14
#openshift_master_portal_net=192.168.77.0/24
openshift_master_portal_net=10.100.0.0/16
#openshift_master_ingress_ip_network_cidr=192.168.77.0/24
openshift_master_external_ip_network_cidrs=['192.168.77.0/24']

# host group for masters
[masters]
node237.localnet.net openshift_ip=192.168.158.237 openshift_hostname=node237.localnet.net openshift_public_ip=192.168.158.237 openshift_public_hostname=node237.localnet.net
node238.localnet.net openshift_ip=192.168.158.238 openshift_hostname=node238.localnet.net openshift_public_ip=192.168.158.238 openshift_public_hostname=node238.localnet.net
node239.localnet.net openshift_ip=192.168.158.239 openshift_hostname=node239.localnet.net openshift_public_ip=192.168.158.239 openshift_public_hostname=node239.localnet.net

# host group for etcd
[etcd]
node237.localnet.net openshift_ip=192.168.158.237 openshift_hostname=node237.localnet.net openshift_public_ip=192.168.158.237 openshift_public_hostname=node237.localnet.net
node238.localnet.net openshift_ip=192.168.158.238 openshift_hostname=node238.localnet.net openshift_public_ip=192.168.158.238 openshift_public_hostname=node238.localnet.net
node239.localnet.net openshift_ip=192.168.158.239 openshift_hostname=node239.localnet.net openshift_public_ip=192.168.158.239 openshift_public_hostname=node239.localnet.net

# Specify load balancer host
[lb]
node108.localnet.net
node109.localnet.net
#lb.openshift-cluster.localnet.net

# host group for nodes, includes region info
[nodes]
node237.localnet.net openshift_node_labels="{'region': 'infra', 'zone': 'default'}" openshift_schedulable=true
node238.localnet.net openshift_node_labels="{'region': 'infra', 'zone': 'default'}" openshift_schedulable=true
node239.localnet.net openshift_node_labels="{'region': 'infra', 'zone': 'default'}" openshift_schedulable=true
node260.localnet.net openshift_node_labels="{'region': 'infra', 'zone': 'default'}"
node261.localnet.net openshift_node_labels="{'region': 'infra', 'zone': 'default'}"
node262.localnet.net openshift_node_labels="{'region': 'infra', 'zone': 'default'}"
node263.localnet.net openshift_node_labels="{'region': 'infra', 'zone': 'default'}"
node264.localnet.net openshift_node_labels="{'region': 'infra', 'zone': 'default'}"

有什么建议吗

您应该创建负载平衡器类型的服务。这是一个例子

apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    app: mysql-ephemeral
    template: mysql-ephemeral-template
  name: mysql-ext
spec:
  ports:
  - name: mysql
    nodePort: 3306
    port: 3306
    protocol: TCP
    targetPort: 3306
  selector:
    name: mysql
  sessionAffinity: None
  type: LoadBalancer

创建服务时,是否将LoadBalancer指定为类型?
# Create an OSEv3 group that contains the master, nodes, etcd, and lb groups.
# The lb group lets Ansible configure HAProxy as the load balancing solution.
# Comment lb out if your load balancer is pre-configured.
[OSEv3:children]
masters
nodes
etcd
lb

# Set variables common for all OSEv3 hosts
[OSEv3:vars]
ansible_ssh_user=root
deployment_type=openshift-enterprise
openshift_router_selector='region=infra'
openshift_registry_selector='region=infra'
use_fluentd=true
debug_level=2
#openshift_release=v3.5
# Install the openshift examples
#openshift_install_examples=true

# Uncomment the following to enable htpasswd authentication; defaults to
# DenyAllPasswordIdentityProvider.
#openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider', 'filename': '/etc/origin/master/htpasswd'}]
# MS AD LDAP Integration
openshift_master_identity_providers=[{ 'name': 'Active_Directory_AELAB', 'challenge': 'true', 'login': 'true', 'kind': 'LDAPPasswordIdentityProvider', 'attributes': { 'id': ['dn'], 'email': ['mail'], 'name': ['cn'], 'preferredUsername': ['uid'] }, 'bindDN': 'cn=srvcKeyStone,ou=Users,ou=Global Info Tech Division,ou=BNYM,dc=aelab,dc=localnet,dc=net', 'bindPassword': 'KeySt0ne1!', 'insecure': 'true', 'url': 'ldap://wsomtapae68.aelab.localnet.net:389/dc=aelab,dc=localnet,dc=net?sAMAccountName' }]

# Defining htpasswd users
openshift_master_htpasswd_file=/opt/openshift/htpasswd

# Native high availbility cluster method with optional load balancer.
# If no lb group is defined installer assumes that a load balancer has
# been preconfigured. For installation the value of
# openshift_master_cluster_hostname must resolve to the load balancer
# or to one or all of the masters defined in the inventory if no load
# balancer is present.
openshift_master_cluster_method=native
openshift_master_cluster_hostname=master.openshift-cluster.localnet.net
openshift_master_cluster_public_hostname=master.openshift-cluster.localnet.net

# apply updated node defaults
# Commenting out 'pods-per-core' variable. Getting error while this value is in place:
#
#[root@node261 xbblrfv]# docker logs df
#Invalid NodeConfig /etc/origin/node/node-config.yaml
#  flag: Invalid value: "pods-per-core": is not a valid flag
#openshift_node_kubelet_args={'pods-per-core': ['10'], 'max-pods': ['250'], 'image-gc-high-threshold': ['90'], 'image-gc-low-threshold': ['80']}
openshift_node_kubelet_args={'max-pods': ['40'], 'image-gc-high-threshold': ['90'], 'image-gc-low-threshold': ['80']}

# override the default controller lease ttl
#osm_controller_lease_ttl=30

# enable ntp on masters to ensure proper failover
openshift_clock_enabled=true

# Configure SDN cluster network and kubernetes service CIDR blocks. These
# network blocks should be private and should not conflict with network blocks
# in your infrastructure that pods may require access to. Can not be changed
# after deployment.

osm_cluster_network_cidr=10.128.0.0/14
#openshift_master_portal_net=192.168.77.0/24
openshift_master_portal_net=10.100.0.0/16
#openshift_master_ingress_ip_network_cidr=192.168.77.0/24
openshift_master_external_ip_network_cidrs=['192.168.77.0/24']

# host group for masters
[masters]
node237.localnet.net openshift_ip=192.168.158.237 openshift_hostname=node237.localnet.net openshift_public_ip=192.168.158.237 openshift_public_hostname=node237.localnet.net
node238.localnet.net openshift_ip=192.168.158.238 openshift_hostname=node238.localnet.net openshift_public_ip=192.168.158.238 openshift_public_hostname=node238.localnet.net
node239.localnet.net openshift_ip=192.168.158.239 openshift_hostname=node239.localnet.net openshift_public_ip=192.168.158.239 openshift_public_hostname=node239.localnet.net

# host group for etcd
[etcd]
node237.localnet.net openshift_ip=192.168.158.237 openshift_hostname=node237.localnet.net openshift_public_ip=192.168.158.237 openshift_public_hostname=node237.localnet.net
node238.localnet.net openshift_ip=192.168.158.238 openshift_hostname=node238.localnet.net openshift_public_ip=192.168.158.238 openshift_public_hostname=node238.localnet.net
node239.localnet.net openshift_ip=192.168.158.239 openshift_hostname=node239.localnet.net openshift_public_ip=192.168.158.239 openshift_public_hostname=node239.localnet.net

# Specify load balancer host
[lb]
node108.localnet.net
node109.localnet.net
#lb.openshift-cluster.localnet.net

# host group for nodes, includes region info
[nodes]
node237.localnet.net openshift_node_labels="{'region': 'infra', 'zone': 'default'}" openshift_schedulable=true
node238.localnet.net openshift_node_labels="{'region': 'infra', 'zone': 'default'}" openshift_schedulable=true
node239.localnet.net openshift_node_labels="{'region': 'infra', 'zone': 'default'}" openshift_schedulable=true
node260.localnet.net openshift_node_labels="{'region': 'infra', 'zone': 'default'}"
node261.localnet.net openshift_node_labels="{'region': 'infra', 'zone': 'default'}"
node262.localnet.net openshift_node_labels="{'region': 'infra', 'zone': 'default'}"
node263.localnet.net openshift_node_labels="{'region': 'infra', 'zone': 'default'}"
node264.localnet.net openshift_node_labels="{'region': 'infra', 'zone': 'default'}"
apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    app: mysql-ephemeral
    template: mysql-ephemeral-template
  name: mysql-ext
spec:
  ports:
  - name: mysql
    nodePort: 3306
    port: 3306
    protocol: TCP
    targetPort: 3306
  selector:
    name: mysql
  sessionAffinity: None
  type: LoadBalancer