Options
All
  • Public
  • Public/Protected
  • All
Menu

@socialgouv/kosko-charts - v9.19.2

Index

Type aliases

EnvironmentName

EnvironmentName: "dev" | "preprod" | "prod"

utils Functions

Const addEnv

  • This function will add an [[EnvVar]] to the first container of a given [[Deployment]]

    import { addEnv } from "@socialgouv/kosko-charts/utils"

    addEnv({
    deployment,
    data: new EnvVar({
    name: "MY_VARIABLE",
    value: "some value"
    })
    })

    Parameters

    Returns void

Const addEnvs

  • addEnvs(__namedParameters: AddEnvsParams): void
  • This function will add a bunch of [[EnvVar]] to the first container of a given [[Deployment]] EnvVars are given as an object

    import { addEnvs } from "@socialgouv/kosko-charts/utils"

    addEnvs({
    deployment,
    data: {
    NODE_ENV: "production",
    TEST: "42"
    }
    })

    Parameters

    • __namedParameters: AddEnvsParams

    Returns void

Const addInitContainer

  • addInitContainer(deployment: Manifest, initContainer: IIoK8sApiCoreV1Container): Manifest
  • This function will add an initContainer to a given [[Deployment]]

    import { addInitContainer } from "@socialgouv/kosko-charts/utils"
    import { Container } from "kubernetes-models/v1/Container";

    const initContainer = new Container({
    args: ["http://www.free.fr"],
    image: `registry.pouet.org/wait-for-http:2.4.0`,
    imagePullPolicy: "Always",
    name: `wait-for-free`,
    });

    addInitContainer(deployment, initContainer);

    Parameters

    • deployment: Manifest
    • initContainer: IIoK8sApiCoreV1Container

    Returns Manifest

Const addInitContainerCommand

  • addInitContainerCommand(deployment: IoK8sApiAppsV1Deployment, container: Partial<IoK8sApiCoreV1Container>): IoK8sApiAppsV1Deployment
  • This function will add an initContainer with the given params to a given [[Deployment]]

    By default the initContainer will use the [[Deployment]] first [[Container]] image as image

    import { addInitContainerCommand } from "@socialgouv/kosko-charts/utils"

    const initContainerCommand = {
    command: ["yarn"],
    args: ["init-db"],
    name: `yarn-init-db`,
    };

    addInitContainerCommand(deployment, initContainerCommand);

    Parameters

    • deployment: IoK8sApiAppsV1Deployment
    • container: Partial<IoK8sApiCoreV1Container>

    Returns IoK8sApiAppsV1Deployment

Const addPostgresUserSecret

  • addPostgresUserSecret(deployment?: IoK8sApiAppsV1Deployment): void
  • This function will add a reference to the default postgres user secret to a given [[Deployment]]

    This secret is named azure-pg-user or azure-pg-user-SHA1 on feature-branches.

    import { addPostgresUserSecret } from "@socialgouv/kosko-charts/utils"

    addPostgresUserSecret(deployment);

    Parameters

    • Optional deployment: IoK8sApiAppsV1Deployment

    Returns void

Const addToEnvFrom

  • This function will add an [[EnvFromSource]] to the first container of a given [[Deployment]]

    Useful to get all variables from a [[ConfigMap]] or a [[Secret]]

    import { addToEnvFrom } from "@socialgouv/kosko-charts/utils"

    addToEnvFrom(deployment, new EnvFromSource({
    secretRef: {
    name: "some-secret"
    }
    }))

    Parameters

    Returns void

Const addWaitForHttp

  • addWaitForHttp(deployment: IoK8sApiAppsV1Deployment, url: string): IoK8sApiAppsV1Deployment
  • This function will add a wait-for-http initContainer to the first container of a given [[Deployment]]

    import { addWaitForHttp } from "@socialgouv/kosko-charts/utils"

    addWaitForHttp(deployment, "http://www.free.fr");

    Parameters

    • deployment: IoK8sApiAppsV1Deployment
    • url: string

    Returns IoK8sApiAppsV1Deployment

Const addWaitForPostgres

  • addWaitForPostgres(deployment: Manifest): Manifest
  • This function will add a wait-for-postgres initContainer to the first container of a given [[Deployment]]

    import { addWaitForPostgres } from "@socialgouv/kosko-charts/utils"

    addWaitForPostgres(deployment);

    Parameters

    • deployment: Manifest

    Returns Manifest

Const addWaitForService

  • addWaitForService(deployment: IoK8sApiAppsV1Deployment, name: string): IoK8sApiAppsV1Deployment
  • This function will add a wait-for-service initContainer to the first container of a given [[Deployment]]

    import { addWaitForService } from "@socialgouv/kosko-charts/utils"

    addWaitForService(deployment, "hasura");

    Parameters

    • deployment: IoK8sApiAppsV1Deployment
    • name: string

    Returns IoK8sApiAppsV1Deployment

Const createDeployment

  • This function will return a [[Deployment]] with some defaults

    import { createDeployment } from "@socialgouv/kosko-charts/utils"

    const deployment = createDeployment({
    name: "app";
    image: "containous/whoami:latest"
    });

    Parameters

    Returns IoK8sApiAppsV1Deployment

Const createIngress

  • createIngress(params: IngressConfig): IoK8sApiNetworkingV1Ingress
  • This function will return an [[Ingress]] with some defaults

    The ingress will listen on given hosts and redirect to given service

    If the ingress has the nginx.ingress.kubernetes.io/permanent-redirect annotation then the hosts will be used only for SSL certificate

    import { createIngress } from "@socialgouv/kosko-charts/utils"

    const ingress = createIngress({
    name: "app-ingress",
    hosts: ["host1.pouet.fr", "host2.pouet.fr"],
    serviceName: "www",
    servicePortName: "http"
    });

    Parameters

    Returns IoK8sApiNetworkingV1Ingress

Const createService

  • This function will return a [[Service]] with some defaults

    import { createService } from "@socialgouv/kosko-charts/utils"

    const service = createService({
    name: "app",
    servicePort: 80,
    containerPort: 3000,
    selector: 80,
    selector: {
    app: "my-target-app"
    }
    });

    Parameters

    Returns IoK8sApiCoreV1Service

Const getDeployment

  • getDeployment(manifests: { kind: string }[]): IoK8sApiAppsV1Deployment
  • This function will return the first [[Deployment]] of a given set of manifests

    import { getDeployment } from "@socialgouv/kosko-charts/utils"

    const deployment = getDeployment(manifests);

    Parameters

    • manifests: { kind: string }[]

    Returns IoK8sApiAppsV1Deployment

Const getHarborImagePath

  • This function will return the full path for a given docker image based on CI_COMMIT_TAG or CI_COMMIT_SHA

    import { getHarborImagePath } from "@socialgouv/kosko-charts/utils"

    const imagePath = getHarborImagePath({
    name: "docker-mario",
    project: "sre", // defaults to process.env.HARBOR_PROJECT
    registry: "chips.registry.com", // defaults to process.env.HARBOR_REGISTRY
    })

    Parameters

    Returns string

Const getIngressHost

  • getIngressHost(manifests: { kind: string }[]): string
  • This function will return the first hostname found in a given list of manifests

    import { getIngressHost } from "@socialgouv/kosko-charts/utils"

    const host = getIngressHost(manifests);

    Parameters

    • manifests: { kind: string }[]

    Returns string

Const getManifestByKind

  • getManifestByKind(manifests: { kind: string }[], manifestType: ManifestType): undefined | IoK8sApiAppsV1Deployment | IoK8sApiNetworkingV1beta1Ingress
  • This function will return the first Manifest in a given set of manifests

    import { getManifestByKind } from "@socialgouv/kosko-charts/utils"
    import type { Ingress } from "kubernetes-models/api/networking/v1beta1/Ingress";

    const deployment = getManifestByKind(manifests, Ingress);

    Parameters

    • manifests: { kind: string }[]
    • manifestType: ManifestType

    Returns undefined | IoK8sApiAppsV1Deployment | IoK8sApiNetworkingV1beta1Ingress

Const getPgServerHostname

  • This function will return the default postgres server hostname for a given app name and environnement

    import { getPgServerHostname } from "@socialgouv/kosko-charts/utils"

    const hostname = getPgServerHostname("app-admin", "prod");

    Parameters

    Returns string

Const waitForHttp

  • This creates a [[Container]] using the wait-for-http docker image

    import { waitForHttp } from "@socialgouv/kosko-charts/utils"

    const container = waitForHttp({
    name: "wait-for-free",
    url: "http://www.free.fr"
    });

    Parameters

    Returns IIoK8sApiCoreV1Container

Const waitForPostgres

  • This creates a [[Container]] using the wait-for-postgres docker image

    import { waitForPostgres } from "@socialgouv/kosko-charts/utils"

    const container = waitForPostgres({
    secretRefName: "some-secret"
    });

    Parameters

    Returns IIoK8sApiCoreV1Container

Const waitForService

  • waitForService(name: string): IIoK8sApiCoreV1Container
  • This creates a [[Container]] that runs until nslookup resolve for the given service in the current kube namespace

    import { waitForService } from "@socialgouv/kosko-charts/utils"

    const container = waitForService({
    name: "hasura"
    });

    Parameters

    • name: string

    Returns IIoK8sApiCoreV1Container

Generated using TypeDoc