nerc-project / operations

Issues related to the operation of the NERC OpenShift environment
2 stars 0 forks source link

OpenShift Virtualization testing—publicly expose non-http services #728

Open computate opened 2 months ago

computate commented 2 months ago
computate commented 1 month ago

I will be working on it this week.

Here are some steps I did to install a PostgreSQL database for testing the VM.

$ sudo yum install -y postgresql-server postgresql-contrib
$ sudo systemctl start postgresql
$ sudo systemctl enable postgresql

$ sudo -u postgres psql
$ create user test password '...';
$ create database test owner test;
$ create table test(pk bigserial primary key, id text unique, val text);

$ postgres=# insert into test(id, val) values('best-linux-flavor', 'rhel9');
INSERT 0 1
$ postgres=# insert into test(id, val) values('best-linux-flavor', 'ubuntu24.04');
ERROR:  duplicate key value violates unique constraint "test_id_key"
computate commented 1 month ago

I added the following template label to my VirtualMachine oc -n virt-test get vm/computate-centos-stream9 for service support for my postgresql server.

spec:
  template:
    metadata:
      labels:
        computate-postgres-test: 'true'

Also add exposed ports to the default interface of the VirtualMachine.

spec:
  template:
    spec:
      domain:
        devices:
          interfaces:
            - name: default
              masquerade: {} 

Specifically add this port:

              ports: 
                - port: 5432
computate commented 1 month ago

Update your postgresql pg_hba.conf file to allow md5 password access to external users.

sudo vim /var/lib/pgsql/data/pg_hba.conf
host all all 0.0.0.0/0 md5
:wq

Also update your postgresql.conf file listen_addresses.

sudo vim /var/lib/pgsql/data/postgresql.conf
listen_addresses = '*'
:wq

Then restart the postgresql service.

sudo systemctl restart postgresql
computate commented 1 month ago
apiVersion: v1
kind: Service
metadata:
  name: computate-postgres-test
  namespace: virt-test
spec:
  selector:
    computate-postgres-test: 'true' 
  type: NodePort 
  ports: 
    - protocol: TCP
      port: 5432
      targetPort: 5432
      nodePort: 30432

Notes:

computate commented 1 month ago

@jtriley says: AFAIK the ingress controller only runs on ports 80 and 443 so unless you're configuring a route to that service, that's not going to work

@larsks says: A nodeport exposes a service on a port on all the worker nodes. The address computate-postgres-test.apps.ocp-test.nerc.mghpcc.org resolves to the cluster load balancer, not to one of the worker nodes. Your nodeport is probably working; try contacting it on one of the worker node addresses. The problem is that this won't do you much good, because the worker nodes are only VPN accessible. To expose non-http services (or services on ports other than 80/443), we need to either install and configure MetalLB, or configure an external cluster load balancer with kubernetes support.

@joachimweyl we have some questions for the NERC team in a future meeting:

computate commented 1 month ago

@jtriley, @larsks, @naved001 Based in the conversation today in the NERC meeting, woud you be able to help with the MetalLB configuration?

naved001 commented 1 month ago

Here are the steps I think we'll need to take:

  1. Get an interface configured on the test cluster worker nodes to be on a public network. This means any necessary VLAN configuration and IP assignment.
  2. Install the metallb operator
  3. configure metallb with an ipaddresspool resource and an l2advertisement. There's also support for BGP but I am not familiar with it.
  4. Take care of the asymmetric routing issue. See https://github.com/CCI-MOC/ops-issues/issues/1376 for more details.

@jtriley since I am not familiar with how public IPs are allocated in the NERC/Harvard environment we'll need your help here.

joachimweyl commented 1 month ago

@computate please provide an update.

computate commented 1 month ago

I don't have additional updates here. We'll need to configure MetalLB next.

computate commented 2 weeks ago

@jtriley do you have a timeframe on when we could do the first step that @naved001 suggested?

Get an interface configured on the test cluster worker nodes to be on a public network. This means any necessary VLAN configuration and IP assignment.

I would like to enable SSH access on some VMs in the test cluster, and also test exposing non-http services, as well as Sensu monitoring agent on a VM to demonstrate event driven remediation of issues on a virtual machine.

computate commented 2 weeks ago

Where I would love to start is actually accessing a VM internally via SSH credentials from Red Hat Ansible Automation Platform deployed in the same namespace as my virtual machines if that is easier to set up and allow. See my aap-controller route in the virt-test namespace.

computate commented 2 weeks ago

Actually, I was able to get internal ssh access to VMs working from Ansible Automation Platform in the same namespace by:

schwesig commented 1 day ago

For now using port forwarding, see NERC weekly Operation rolling agenda please comment/emoticon a yes