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

chore: change namespace to hns-system instead of sns-system #207

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ jobs:
run: make test-e2e

- name: Undeploy HNS
run: make undeploy
run: make undeploy
if: always()
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ dev: manifests kustomize
$(KUSTOMIZE) build config/dev | oc apply -f -
mkdir -p $(LOCAL_CERT_DIR)
sleep 3
kubectl get secret webhook-server-cert -n sns-system -o jsonpath="{.data.tls\.crt}" | base64 --decode > $(LOCAL_CERT_DIR)/tls.crt
kubectl get secret webhook-server-cert -n sns-system -o jsonpath="{.data.tls\.key}" | base64 --decode > $(LOCAL_CERT_DIR)/tls.key
kubectl get secret webhook-server-cert -n hns-system -o jsonpath="{.data.tls\.crt}" | base64 --decode > $(LOCAL_CERT_DIR)/tls.crt
kubectl get secret webhook-server-cert -n hns-system -o jsonpath="{.data.tls\.key}" | base64 --decode > $(LOCAL_CERT_DIR)/tls.key

.PHONY: undev
undev: manifests kustomize
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ In order to use `HNS`, you need to have:

## Install with Helm

Helm chart docs are available on `charts/hns` directory. The release name must be `sns`:
Helm chart docs are available on `charts/hns` directory.

```bash
$ helm upgrade sns --install --namespace sns-system --create-namespace oci://ghcr.io/dana-team/helm-charts/hns --version <release>
$ helm upgrade hns --install --namespace hns-system --create-namespace oci://ghcr.io/dana-team/helm-charts/hns --version <release>
```

### Build
Expand Down
4 changes: 2 additions & 2 deletions api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ type Phase string
const MetaGroup = "dana.hns.io/"

const (
SNSNamespace = "sns-system"
SNSServiceAccount = "sns-controller-manager"
HNSNamespace = "hns-system"
HNSServiceAccount = "hns-controller-manager"
)

var DefaultAnnotations = []string{"scheduler.alpha.kubernetes.io/defaultTolerations", "openshift.io/node-selector"}
Expand Down
2 changes: 1 addition & 1 deletion charts/hns/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
name: sns
name: hns
description: A Helm chart for the hns operator.

# A chart can be either an 'application' or a 'library' chart.
Expand Down
4 changes: 2 additions & 2 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Adds namespace to all resources.
namespace: sns-system
namespace: hns-system

# Value of this field is prepended to the
# names of all resources, e.g. a deployment named
# "wordpress" becomes "alices-wordpress".
# Note that it should also match with the prefix (text before '-') of the namespace
# field above.
namePrefix: sns-
namePrefix: hns-

# Labels to add to all resources and selectors.
#labels:
Expand Down
4 changes: 2 additions & 2 deletions config/dev/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Adds namespace to all resources.
namespace: sns-system
namespace: hns-system

# Value of this field is prepended to the
# names of all resources, e.g. a deployment named
# "wordpress" becomes "alices-wordpress".
# Note that it should also match with the prefix (text before '-') of the namespace
# field above.
namePrefix: sns-
namePrefix: hns-

# Labels to add to all resources and selectors.
#labels:
Expand Down
1 change: 0 additions & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ configMapGenerator:
- literals:
- resources="basic.storageclass.storage.k8s.io/requests.storage,cpu,memory,pods,requests.nvidia.com/gpu"
name: quota-resources
namespace: sns-system
options:
disableNameSuffixHash: true
2 changes: 1 addition & 1 deletion internal/common/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func ValidatePermissions(ctx context.Context, aNS []string, aNSName, bNSName, an
// It returns a boolean value indicating whether the user has permission to create the pod or not.
func permissionsExist(ctx context.Context, reqUser, namespace string) (bool, error) {

if reqUser == fmt.Sprintf("system:serviceaccount:%s:%s", danav1.SNSNamespace, danav1.SNSServiceAccount) {
if reqUser == fmt.Sprintf("system:serviceaccount:%s:%s", danav1.HNSNamespace, danav1.HNSServiceAccount) {
return true, nil
}

Expand Down
7 changes: 4 additions & 3 deletions internal/quota/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"fmt"

danav1 "github.com/dana-team/hns/api/v1"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/types"
Expand All @@ -26,14 +28,13 @@ type resourceQuantities struct {
}

const (
namespaceName = "sns-system"
configMapName = "sns-config"
configMapName = "hns-config"
)

// getConfigMapData retrieves the ConfigMap data from the cluster.
func getConfigMapData(ctx context.Context, k8sClient client.Client, key string) (string, error) {
cm := &corev1.ConfigMap{}
err := k8sClient.Get(ctx, types.NamespacedName{Name: configMapName, Namespace: namespaceName}, cm)
err := k8sClient.Get(ctx, types.NamespacedName{Name: configMapName, Namespace: danav1.HNSNamespace}, cm)
if err != nil {
return "", err
}
Expand Down
6 changes: 4 additions & 2 deletions internal/quota/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"
"strings"

danav1 "github.com/dana-team/hns/api/v1"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -32,7 +34,7 @@ var (
imagestreams = resource.NewQuantity(100, resource.DecimalSI)
ZeroDecimal = resource.NewQuantity(0, resource.DecimalSI)

quotaConfig = "sns-quota-resources"
quotaConfig = "hns-quota-resources"

DefaultQuota = corev1.ResourceQuotaSpec{Hard: DefaultQuotaHard}

Expand All @@ -46,7 +48,7 @@ var (
// The observed resources are read from a configMap.
func GetObservedResources(ctx context.Context, k8sClient client.Client) (corev1.ResourceQuotaSpec, error) {
resourcesConfig := &corev1.ConfigMap{}
if err := k8sClient.Get(ctx, types.NamespacedName{Name: quotaConfig, Namespace: namespaceName}, resourcesConfig); err != nil {
if err := k8sClient.Get(ctx, types.NamespacedName{Name: quotaConfig, Namespace: danav1.HNSNamespace}, resourcesConfig); err != nil {
return corev1.ResourceQuotaSpec{}, fmt.Errorf("failed to get ConfigMap %q: %v", resourcesConfig, err)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/subnamespace/deletevalidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (v *SubnamespaceValidator) handleDelete(req admission.Request) admission.Re
// validateServiceAccount validates that the account requesting the deletion of a subnamespace
// is the service account of the sns operator. Otherwise it will deny the request
func (v *SubnamespaceValidator) validateServiceAccount(userName string) admission.Response {
if userName != fmt.Sprintf("system:serviceaccount:%s:%s", danav1.SNSNamespace, danav1.SNSServiceAccount) {
if userName != fmt.Sprintf("system:serviceaccount:%s:%s", danav1.HNSNamespace, danav1.HNSServiceAccount) {
return admission.Denied(fmt.Sprintf("%q is not allowed to delete subnamespaces", userName))

}
Expand Down