nearbyone-controller

by joaquinito2051

Helm chartv2.119.1App 1.16.0

A Helm chart for Kubernetes

About this chart

NearbyOne Controller

Helm chart to deploy NearbyOne Controller

Helm Installation

Setup

In order to pull images from external sources, you will need to add these repos to your helm client. In the case of Ory Kratos, imported in nearbyone/Chart.yaml:

 - name: kratos
    version: ~0.20.0
    repository: https://k8s.ory.sh/helm/charts
    condition: kratos.enabled

Run:

helm repo add ory https://k8s.ory.sh/helm/charts

Do this for each external dependency

After this is complete, run:

helm dependency update helm/charts/nearbyone/

To install an env on a cluster, you must first have the correct kubeconfig set as your current context in kubectl.

Configuration

Default values are in file helm/charts/nearbyone/values.yaml, and are tuned for a default OKD/Openshift install. Nonetheless, some of those values MUST be overridden and others MUST be added, depending on the actual environment. The place to do this is under envs/${ENV_FILENAME}.yaml. Files under env-templates/ are meant to be used as starting points to create the actual ones.

Support matrix

Supported kubernetes environments: OKD/Openshift (on user-provided resources), Vanilla k8s, AWS eks, Azure AKS.

Supported Ingresses: haproxy (default for OKD/Openshift), ingress-nginx, ALB (eks only).

Supported TLS Certificate operators: cert-manager.

Supported Load Balancers: metalLB, NLB/ALB (eks only), AzureLB (Azure only).

CombinationclusterTypeingressTypecertOperatormetallb.enabledingress-nginx.enabled
OKD/metalLB/haproxy/cert-manageropenshifthaproxycert-managerfalse (must be installed beforehand)false
Vanilla/metalLB/ingress-nginx/cert-managervanillaingress-nginxcert-managertrue (if not present)true (if not present)
eks/AwsLB/ingress-nginx/cert-managereksingress-nginxcert-managerfalsetrue
aks/AzureLB/ingress-nginx/cert-manageraksingress-nginxcert-managerfalsetrue (if not present)
OKD/AwsLB/haproxy/cert-managerokdhaproxycert-managerfalsefalse

NOTE: cert-manager, when used MUST always be installed beforehand. For OKD, it can be installed from the Operator Hub. For vanilla, with the normal yaml installation or helm chart. When not running on OKD or Openshift, the quickest way is to just run kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.7.0/cert-manager.yaml (replace 1.7.0 with the release current at the time of installation).

NearbyOne and DNS

NearbyOne needs to interact and make changes to the DNS for the following operations:

  1. Dynamic creation of DNS names for externally-visible services
  2. Dynamic generation of TLS certificates (eg using the ACME protocol with DNS-01 challenge)

NearbyOne accomplishes 1) with external-dns, and 2) with cert-manager (or nothing if the certificate is pre-provisioned, for example with AWS ACM).

The DNS does not need to be provided by the same provider which hosts the kubernetes cluster. For example, the kubernetes cluster could be on-premise or in AKS, while the DNS could be hosted on AWS route53, Google cloud DNS or an on-premise DNS server (eg bind). Also, the DNS provider used for point 1) above need not be the same used for 2) (although they are usually the same).

For this reason, NearbyOne needs to be configured with the information necessary to access the appropriate DNS provider.

Here are the instructions to prepare the DNS providers currently supported.

AWS Route 53

There are two supported authentication methods: using plain IAM credentials (ie access key + secret key), which always works regardless of where the cluster is running, or using a pre-existing IAM role to be linked to a kubernetes service account, which only works if the cluster is EKS.

The IAM role should be created with the policy shown here: https://github.com/kubernetes-sigs/external-dns/blob/master/docs/tutorials/aws.md#iam-policy. It then needs to have a trust relationship created with the cluster's OIDC provider, as explained here: https://docs.aws.amazon.com/eks/latest/userguide/create-service-account-iam-policy-and-role.html#create-service-account-iam-role.

Cloudflare

You can configure access using the API token or the combination of API Key + email address. Only one or the other must be used.

Google Cloud DNS

The DNS zone must already exist in cloud DNS, associated to some project. You need to create a google cloud IAM service account with the appropriate permissions to manage the DNS zone, and then a service account key, which you will need to configure NearbyOne. Here is an overview of the steps to do the above (in this case the service account is called dnsupdater):

$ gcloud iam service-accounts create dnsupdater \
    --display-name "Service account for ExternalDNS on GCP"
Created service account [dnsupdater].

$ gcloud projects add-iam-policy-binding <GCP_PROJECT_ID> \
    --role='roles/dns.admin' \
    --member='serviceAccount:dnsupdater@<GCP_PROJECT_ID>.iam.gserviceaccount.com'
...

$ gcloud iam service-accounts keys create credentials.json \
    --iam-account dnsupdater@<GCP_PROJECT_ID>.iam.gserviceaccount.com

RFC2136 (aka "dynamic-dns")

On the bind side, you need to create a TSIG secret and give it permissions for dynamic updates and zone transfers:

$ ddns-confgen -r /dev/urandom -a hmac-sha512 -s example.com
...

# in your named.conf or equivalent
key "externaldns-key" {
        algorithm hmac-sha256;
        secret "96Ah/a2g0/nLeFGK+d/0tzQcccf9hCEIy34PoXX2Qg8=";
};

zone "example.com" {
        allow-transfer { key "externaldns-key"; };
        update-policy { grant "externaldns-key" zonesub ANY; };
}

For convenience, all DNS configuration is centralized under the externaldns key in values.yaml. If the DNS providers used for 1) and 2) are the same, NearbyOne is able to extract all the information it needs from this block. Following is an example block, with commented values:

externaldns:
  enabled: true
  logLevel: "info"
  txtPrefix: "externaldns-"
  serviceAccount:
    create: true
    name: "externaldns-sa"
  policy: "upsert-only"
  triggerLoopOnEvent: true
  domainFilters:
    - "nearbycomputing.com"
  sources:
    - "service"
    - "ingress"

  # only if provider "aws" with IAM role ARN
  #serviceAccount:
  #  annotations:
  #    eks.amazonaws.com/role-arn: "arn:aws:iam::333333333333:role/DnsUpdater"

  provider: "aws"

  # only if provider for certs is different
  # provider_for_acme: "google"

  aws:
    region: "eu-west-1"
    credentials:
      accessKey: "AKIAAAAAAAAAAAAAAAAAA"
      secretKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    zoneType: "public"

  #cloudflare:
  #  # use one of apiToken OR email + apiKey, not both
  #  apiToken: "xxxxxxxxxxxxx"
  #
  #  email: "[email protected]"
  #  apiKey: "xxxxxx"
  #  proxied: false

  #google:
  #  project: "testproject-444444"     # this is the project id, NOT the name!
  #  serviceAccountKey: |
  #    {
  #      "type": "service_account",
  #      "project_id": "testproject-444444",
  #      "private_key_id": "912e721458737f432fab789cd1ed332be73c049b",
  #      ...
  #  zoneVisibility: "public"

  #rfc2136:
  #  host: "10.1.1.1"
  #  port: 53
  #  zone: "nearbycomputing.com"
  #  tsigSecret: "96Ah/a2g0/nLeFGK+d/0tzQcccf9hCEIy34PoXX2Qg8="
  #  tsigSecretAlg: "hmac-sha512"
  #  tsigKeyname: "externaldns-key"
  #  tsigAxfr: true


ACME configuration is done in the ACME block, currently supported providers include Let's Encrypt and any provider supporting AEB (External Account Binding) (eg ZeroSSL, SSL.com).

ACME:
  provider: "le"
  le:
    email: "[email protected]"
    server: "https://acme-v02.api.letsencrypt.org/directory"
  lestaging:
    email: "[email protected]"
    server: "https://acme-staging-v02.api.letsencrypt.org/directory"

  # EAB accounts
  #zerossl:
  #  server: "https://acme.zerossl.com/v2/DV90"
  #  eab_kid: "GPmbSQG_FsKO49dgEjjA3g"
  #  eab_hmac_key: "KxDNl61A3vCWdKIWYPY_mDQWG0-tfSNNHxbyLrl2f2BRFcfNtstsC4GOtMnVf-K4tpHl9x1-cwMLPgM8bHUOLg"

  #sslcom:
  #  server: "https://acme.ssl.com/sslcom-dv-rsa"
  #  eab_kid: "ee4c1e5918b2"
  #  eab_hmac_key: "NtGz49AkBiRhGuOi2W2CX5pYn7wR1MHOz_GPqGjkHB4"

Prerequisites

EKS on AWS

Nearbyone creates load balanced IPs and applications, so the cluster needs to have an AWS Load Balancer Controller deployed and available. See here for installation instructions: https://docs.aws.amazon.com/eks/latest/userguide/aws-load-balancer-controller.html.

Since the only certificate operator supported on EKS is ACM (AWS Certificate Manager), a certificate for whatever domain is used as external domain name for the cluster must have been generated in ACM beforehand.

Both conditions are met if you create the cluster using NearbyComputing's terraform modules for EKS.

AKS on Azure

Cert-manager must be present on the cluster to get certificates.

If you provision the cluster using NearbyComputing's terraform module for AKS, cert-manager is installed by default.

Due to a bug, before running helm upgrade you should delete ingress-nginx validating web hook configuration: kubectl delete ValidatingWebhookConfiguration nby-ingress-nginx-admission (to be investigated, seems related to konnectivity).

OKD/Openshift on AWS

Cert-manager must be installed before installing Nearbyone. Cert-manager can be installed from the operator marketplace.

Installation & Upgrade

To install or upgrade:

helm upgrade --install --create-namespace --debug -n $ENVNAMESPACE $ENVNAME helm/charts/nearbyone/

Credentials

The default values.yaml is missing some credentials that must be provided at install time. helm lint will fail unless these credentials are provided. See values.yaml for a description of each of these keys.

Deploy nearbyone-controller with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has nearbyone-controller on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartnearbyone-controller is pinned at v2.119.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply