Skip to content

[WIP] HiveCluster CR restricted securityContext & volumes - #6811

Open
tanishq-chugh wants to merge 3 commits into
apache:masterfrom
tanishq-chugh:cr-security-context
Open

tanishq-chugh wants to merge 3 commits into
apache:masterfrom
tanishq-chugh:cr-security-context

Conversation

@tanishq-chugh

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Why are the changes needed?

Does this PR introduce any user-facing change?

How was this patch tested?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

One or more issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 3 Medium severity

Open (4)
What changed in this PR

This WIP hardens HiveCluster-generated Kubernetes workloads with restricted security contexts, safer volume schemas, and ServiceAccount approval checks.

Changes:

  • Adds restricted volume types and updates the CRD.
  • Applies non-root, seccomp, capability, and privilege-escalation restrictions.
  • Adds configurable runAsUser and ServiceAccount validation.
File Description
packaging/​src/​kubernetes/​src/​java/​org/​apache/​hive/​kubernetes/​operator/​reconciler/​HiveClusterReconciler.java Updated as part of this pull request.
packaging/​src/​kubernetes/​src/​java/​org/​apache/​hive/​kubernetes/​operator/​model/​spec/​TezAmSpec.java Updated as part of this pull request.
packaging/​src/​kubernetes/​src/​java/​org/​apache/​hive/​kubernetes/​operator/​model/​spec/​RestrictedVolume.java Updated as part of this pull request.
packaging/​src/​kubernetes/​src/​java/​org/​apache/​hive/​kubernetes/​operator/​model/​spec/​MetastoreSpec.java Updated as part of this pull request.
packaging/​src/​kubernetes/​src/​java/​org/​apache/​hive/​kubernetes/​operator/​model/​spec/​LlapSpec.java Updated as part of this pull request.
packaging/​src/​kubernetes/​src/​java/​org/​apache/​hive/​kubernetes/​operator/​model/​spec/​HiveServer2Spec.java Updated as part of this pull request.
packaging/​src/​kubernetes/​src/​java/​org/​apache/​hive/​kubernetes/​operator/​model/​HiveClusterSpec.java Updated as part of this pull request.
packaging/​src/​kubernetes/​src/​java/​org/​apache/​hive/​kubernetes/​operator/​dependent/​SchemaInitJobDependent.java Updated as part of this pull request.
packaging/​src/​kubernetes/​src/​java/​org/​apache/​hive/​kubernetes/​operator/​dependent/​MetastoreDeploymentDependent.java Updated as part of this pull request.
packaging/​src/​kubernetes/​src/​java/​org/​apache/​hive/​kubernetes/​operator/​dependent/​LlapResourceBuilder.java Updated as part of this pull request.
packaging/​src/​kubernetes/​src/​java/​org/​apache/​hive/​kubernetes/​operator/​dependent/​HiveServer2DeploymentDependent.java Updated as part of this pull request.
packaging/​src/​kubernetes/​src/​java/​org/​apache/​hive/​kubernetes/​operator/​dependent/​HiveDependentResource.java Updated as part of this pull request.
packaging/​src/​kubernetes/​helm/​hive-operator/​values.yaml Updated as part of this pull request.
packaging/​src/​kubernetes/​helm/​hive-operator/​templates/​hivecluster.yaml Updated as part of this pull request.
packaging/​src/​kubernetes/​helm/​hive-operator/​templates/​clusterrole.yaml Updated as part of this pull request.
packaging/​src/​kubernetes/​helm/​hive-operator/​crds/​hiveclusters.hive.apache.org-v1.yml Updated as part of this pull request.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +643 to +645
if (runAsUser != null) {
podSc.withRunAsUser(runAsUser);
}
Comment on lines +429 to +431
if (serviceAccountName == null || serviceAccountName.isBlank()) {
return;
}
Comment on lines +432 to +435
var sa = client.serviceAccounts().inNamespace(namespace).withName(serviceAccountName).get();
if (sa == null) {
throw new IllegalArgumentException(
"serviceAccountName '" + serviceAccountName + "' not found in namespace " + namespace);
Comment on lines +50 to +58
public Volume toKubernetesVolume() {
return new VolumeBuilder()
.withName(name)
.withConfigMap(configMap)
.withSecret(secret)
.withEmptyDir(emptyDir)
.withPersistentVolumeClaim(persistentVolumeClaim)
.build();
}
@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants