Skip to main content

ArgoKit v2

ArgoKit Logo

ArgoKit v2 is a set of reusable jsonnet templates, building on the old argoKit, that makes it easier to deploy ArgoCD applications on SKIP. It is a work in progress and will be updated as we learn more about how to best deploy with ArgoCD on SKIP. If you have any questions, please reach out to the #gen-argocd or #spire-kartverket-devex-sparring channels in Slack.

Installationโ€‹

Assuming you have followed the Getting Started guide, you can use ArgoKit in your apps-repo.

First you need to install jsonnet bundler. This is done by running brew install jsonnet-bundler or download the binary release. Next run jb init, and finally run jb install github.com/kartverket/argokit@main. If you want to stay on a specific version use jb install github.com/kartverket/argokit@2.0.0

Remember to add vendor/ to .gitignore

Git submodulesโ€‹

Alternatively you can use submodules if you prefer it over jsonnet bundler (We recommend jsonnet bundler). Include the ArgoKit library by running the following command:

$ git submodule add https://github.com/kartverket/argokit.git

Automatic version updatesโ€‹

It is highly recommended to use dependabot to automatically update the ArgoKit version when a new version is released. To do this, add the following to your .github/dependabot.yml file:

version: 2
updates:
- package-ecosystem: gitsubmodule
directory: /
schedule:
interval: daily

With this configuration, dependabot will automatically create a PR to update the ArgoKit version once a day provided that a new version has been released.

Usageโ€‹

If you use jsonnet in your apps-repo, you can use the ArgoKit library to deploy ArgoCD applications by including the argokit.libsonnet file in your jsonnet file and calling the argokit.Application function. For example, to deploy an application, you can use the following jsonnet file:

local argokit = import 'github.com/kartverket/argokit/v2/jsonnet/argokit.libsonnet';

argokit.application.new('foo-backend')
+argokit.application.withReplicas(initial=2, max=5, targetCpuUtilization=80)
+argokit.application.forHostnames('foo.bar.com')
+argokit.application.withInboundSkipApp('foo-frontend')

jsonnet argokit APIโ€‹

The following examples are available at our github

TemplateDescriptionExample
argokit.application.new()Creates a Skiperator application, using the appAndObjects convention (this is default).See above
argokit.skipJob.new()Creates a Skiperator job, using the appAndObjects convention.examples/accessPolicies-for-job.jsonnet

argoKit's Replicas APIโ€‹

NOTE! It is not recommended to run with less than 2 replicas...

TemplateDescriptionExample
argokit.application.withReplicasCreate replicas for an application with sensible defaultsexamples/replicas.jsonnet
argokit.application.withReplicasCreate replicas for an application with memory monitoringexamples/replicasets-with-memory.jsonnet
argokit.application.withReplicasCreates a static replica without cpu- and memory monitoringexamples/replicasets-static.jsonnet

argoKit's Environment APIโ€‹

TemplateDescriptionExample
argokit.[application|skipJOB].withVariableCreates environment variables for an appexamples/envVariables.jsonnet
argokit.[application|skipJOB].withVariableSecretCreates environment variable from a secretexamples/envVariables.jsonnet
argokit.[application|skipJOB].withVariableSecretCreates environment variable from a secret for a Job containerexamples/envVariables.jsonnet

argoKit's Ingress APIโ€‹

TemplateDescriptionExample
argokit.application.forHostnameCreates ingress for an app or a jobexamples/ingress.jsonnet

argoKit's accessPolicies APIโ€‹

You can define what external services (hosts/IPs) and internal SKIP applications your app or job may communicate with.
All functions work for both applications and skipJobs: argokit.application.* or argokit.skipJob.*.

TemplateDescriptionExample
argokit.[application|skipJob].withOutboundPostgres(host, ip)Allow outbound traffic to a Postgres instanceexamples/accessPolicies-for-job.jsonnet
argokit.[application|skipJob].withOutboundOracle(host, ip)Allow outbound traffic to an Oracle DBexamples/accessPolicies-for-job.jsonnet
argokit.[application|skipJob].withOutboundSsh(host, ip)Allow outbound SSHexamples/accessPolicies-for-job.jsonnet
argokit.[application|skipJob].withOutboundLdaps(host, ip)Allow outbound secure LDAP portexamples/accessPolicies-for-job.jsonnet
argokit.[application|skipJob].withOutboundHttp(host, portname='', port=443, protocol='')Allow outbound HTTPS/HTTP to a hostexamples/accessPolicies-for-job.jsonnet
argokit.[application|skipJob].withOutboundSkipApp(appname, namespace='')Allow outbound traffic to another SKIP application (outbound rule)examples/accessPolicies-for-job.jsonnet
argokit.[application|skipJob].withInboundSkipApp(appname, namespace='')Allow another SKIP application to reach this one (inbound rule)examples/accessPolicies-for-job.jsonnet

argoKit's Probe APIโ€‹

Configure health probes for applications and skipJobs.

TemplateDescriptionExample
argokit.[application|skipJob].probe(path, port, failureThreshold=3, timeout=1, initialDelay=0)Builds a probe object (path, port, thresholds)-
argokit.[application|skipJob].withReadiness(probe)Adds a readiness probe (controls when traffic is sent to the pod)examples/probes
argokit.[application|skipJob].withLiveness(probe)Adds a liveness probe (restarts container if failing)examples/probes
argokit.[application|skipJob].withStartup(probe)Adds a startup probe (gates other probes until it succeeds)examples/probes

Contributingโ€‹

Contributions are welcome! Please open an issue or PR if you would like to see something changed or added.

Licenseโ€‹

ArgoKit is licensed under the MIT License. See LICENSE for the full license text.