Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid mounting dbadmin password if not needed #396

Merged
merged 2 commits into from
May 12, 2023

Conversation

spilchen
Copy link
Collaborator

Currently, the dbadmin password is mounted in the container at /etc/podinfo/superuser-passwd. This is needed so that readiness/startup probes can log into vertica and run the 'select 1' canary query. This change is to satisfy a request to avoid mounting the password if the probes are change to not refer to the password.

There are two ways you can change the probes:

  1. Check if the client port is open.

Instead of checking the canary query. Just check if the client port is opened. Include overrides for the readiness and startup probes in the vdb like this:

apiVersion: vertica.com/v1beta1
kind: VerticaDB
metadata:
  name: v
spec:
  ...
  readinessProbeOverride:
    tcpSocket:
      port: 5433
  startupProbeOverride:
    tcpSocket:
      port: 5433
  1. Setup local trust for the dbadmin

Keep using the canary query but setup local trust for dbadmin so a password isn't needed. After the database is up, setup a local trust using SQL like the following:

CREATE AUTHENTICATION v_dbadmin_trust METHOD 'trust' LOCAL;
GRANT AUTHENTICATION v_dbadmin_trust TO dbadmin;
ALTER AUTHENTICATION v_dbadmin_trust PRIORITY 10000;
SELECT sync_catalog();

This can be included in an EventTrigger so that it's done automatically after a DB was created. Then create the vdb with an override for the command.

apiVersion: vertica.com/v1beta1
kind: VerticaDB
metadata:
  name: v
spec:
  readinessProbeOverride:
    exec:
      command: ["vsql", "-c", "select 1"]
  startupProbeOverride:
    exec:
      command: ["vsql", "-c", "select 1"]

In both cases, the operator was changed to not include the mount if we no longer reference dbadmin password in any of the probes.

Currently, the dbadmin password is mounted in the container at
/etc/podinfo/superuser-passwd. This is needed so that readiness/startup probes
can log into vertica and run the 'select 1' canary query. This change is to
satisfy a request to avoid mounting the password if the probes are change to
not refer to the password.

There are two ways you can change the probes:

1. Check if the client port is open.

Instead of checking the canary query. Just check if the client port is opened.
Include overrides for the readiness and startup probes in the vdb like this:

```
apiVersion: vertica.com/v1beta1
kind: VerticaDB
metadata:
  name: v
spec:
  ...
  readinessProbeOverride:
    tcpSocket:
      port: 5433
  startupProbeOverride:
    tcpSocket:
      port: 5433
```

2. Setup local trust for the dbadmin

Keep using the canary query but setup local trust for dbadmin so a password
isn't needed. After the database is up, setup a local trust using SQL like the
following:

```
CREATE AUTHENTICATION v_dbadmin_trust METHOD 'trust' LOCAL;
GRANT AUTHENTICATION v_dbadmin_trust TO dbadmin;
ALTER AUTHENTICATION v_dbadmin_trust PRIORITY 10000;
SELECT sync_catalog();
```

This can be included in an EventTrigger so that it's done automatically after a
DB was created. Then create the vdb with an override for the command.

```
apiVersion: vertica.com/v1beta1
kind: VerticaDB
metadata:
  name: v
spec:
  readinessProbeOverride:
    exec:
      command: ["vsql", "-c", "select 1"]
  startupProbeOverride:
    exec:
      command: ["vsql", "-c", "select 1"]
```

In both cases, the operator was changed to not include the mount if we no
longer reference dbadmin password in any of the probes.
@spilchen spilchen requested a review from roypaulin May 11, 2023 18:14
@spilchen spilchen self-assigned this May 11, 2023
Copy link
Collaborator

@roypaulin roypaulin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just have one question.

@spilchen spilchen merged commit 24f15ac into vertica:main May 12, 2023
@spilchen spilchen deleted the hide-su-passwd branch May 12, 2023 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants