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

Allow the ServiceAccount to be specified for vertica server pods #521

Merged
merged 10 commits into from
Sep 30, 2023

Conversation

spilchen
Copy link
Collaborator

This allows the serviceAccount to be specified for the vertica server pods. Now that the operator runs at cluster scope, we have separated the service account used to run the operator with the one to run the vertica server pods. In #514 the operator will generate the service account, along with a role and rolebinding, to use. This takes it one step further and allow the user to create the service account ahead of time.

This allows for better integration where the service account needs to be created ahead of time to setup access (e.g. IAM profile via AWS IRSA).

The vertica server pod needs to have read access to k8s secrets in order to read certs. So, a role and rolebinding must be attached to the service account.

One way that someone could use this:

  1. Create the ServiceAccount. If setting up IRSA, this step could include adding an AWS annotation so that the serviceAccount has access to a particular IAM profile.
    kubectl create serviceaccount vertica-server-sa
  2. Create the role that the vertica server needs:
    kubectl create -f config/rbac/vertica-server-role.yaml # This will be available as a release artifact too
  3. Create the rolebinding to link the two:
    kubectl create rolebinding vertica-server-rolebinding --role vertica-server-role --serviceaccount=<namespace>:<serviceAccountName>
  4. Create the VerticaDB and fill in the spec.serviceAccountName field with the name of the service account (e.g. vertica-server-sa)

Note, if the service account name is specified, then we assume the necessary role and rolebindings are setup too. The operator will only generate those if it generates the service account also.

@spilchen spilchen self-assigned this Sep 27, 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!

# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: vertica.com/v1beta1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Couldn't we also test that if the sa doesn't exist but the role and rolebinding do then only the sa is created with the specified name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The operator cannot find user created role/rolebinding. So, if the sa is deleted the operator will generate that along with new role/rolebindings. I'll expand this test to include that scenario.

// The name of a serviceAccount to use to run the Vertica pods. If this is
// omitted or the serviceAccount doesn't exist, the operator will create one
// along with a Role and RoleBinding.
ServiceAccountName string `json:"serviceAccountName,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it worth mentioning that "If this is omitted or the serviceAccount does't exist, the operator will create one with respectively an internal generated name or the specified name, as well as a Role and RoleBinding."

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How about this?
If the service account is not specified or does not exist, the operator will create one, using the specified name if provided, along with a Role and RoleBinding.

@spilchen spilchen merged commit f946b70 into main Sep 30, 2023
25 checks passed
@spilchen spilchen deleted the spilchen/allow-sa-override branch September 30, 2023 20:55
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