GitHub Action to create Kubernetes cluster secrets
Перейти к файлу
dependabot[bot] 3eb9ef776f
Bump the actions group across 1 directory with 3 updates (#114)
Bumps the actions group with 3 updates in the / directory: [@kubernetes/client-node](https://github.com/kubernetes-client/javascript), [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) and [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node).


Updates `@kubernetes/client-node` from 0.22.1 to 0.22.2
- [Release notes](https://github.com/kubernetes-client/javascript/releases)
- [Changelog](https://github.com/kubernetes-client/javascript/blob/master/CHANGELOG.md)
- [Commits](https://github.com/kubernetes-client/javascript/compare/0.22.1...0.22.2)

Updates `@types/jest` from 29.5.13 to 29.5.14
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest)

Updates `@types/node` from 22.7.7 to 22.8.7
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@kubernetes/client-node"
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: "@types/jest"
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-06 15:06:10 -05:00
.github
src
test
.gitignore
.prettierignore
.prettierrc.json
CHANGELOG.md
CODE_OF_CONDUCT.md
LICENSE
README.md
SECURITY.md
action.yml
jest.config.js
package-lock.json Bump the actions group across 1 directory with 3 updates (#114) 2024-11-06 15:06:10 -05:00
package.json Bump the actions group across 1 directory with 3 updates (#114) 2024-11-06 15:06:10 -05:00
tsconfig.json

README.md

Kubernetes create secret

Create a generic secret or docker-registry secret in Kubernetes cluster, replacing the secret if it already exists.

The secret will be created in the cluster context which was set earlier in the workflow by using either azure/aks-set-context or azure/k8s-set-context

Refer to the action metadata file for details about all the inputs https://github.com/Azure/k8s-create-secret/blob/master/action.yml

For docker-registry type secrets, the fields .dockercfg or .dockerconfigjson can be supplied in plaintext on the string-data JSON object, or base64 encoded on the data JSON object as included in the docker-config-secrets section.

Sample workflow for docker-registry secret (imagepullsecret, stringData)

# File: .github/workflows/workflow.yml

on: push

jobs:
   example-job:
      runs-on: ubuntu-latest
      steps:
         - name: Set imagePullSecret
           uses: azure/k8s-create-secret@v4
           with:
              namespace: 'myapp'
              secret-name: 'contoso-cr'
              container-registry-url: 'containerregistry.contoso.com'
              container-registry-username: ${{ secrets.REGISTRY_USERNAME }}
              container-registry-password: ${{ secrets.REGISTRY_PASSWORD }}
           id: create-secret

Sample workflow for generic secret (base64 data)

# File: .github/workflows/workflow.yml

on: push

jobs:
   example-job:
      runs-on: ubuntu-latest
      steps:
         - uses: azure/k8s-create-secret@v2
           with:
              namespace: 'default'
              secret-type: 'generic'
              secret-name: azure-storage
              data: ${{ secrets.AZURE_STORAGE_ACCOUNT_DATA }}

Alternative for Container Registry Secrets

Get the username and password of your container registry and create secrets for them. For Azure Container registry refer to admin account document for username and password.

For creating docker-registery secrets, kubectl can generate the JSON

kubectl create secret docker-registry secret-tiger-docker \
  --docker-username=tiger \
  --docker-password=pass113 \
  --docker-email=tiger@acme.com \
  --docker-server=my-registry.example:5000

Example output:

{
    "apiVersion": "v1",
    "data": {
        ".dockerconfigjson": "eyJhdXRocyI6eyJteS1yZWdpc3RyeTo1MDAwIjp7InVzZXJuYW1lIjoidGlnZXIiLCJwYXNzd29yZCI6InBhc3MxMTMiLCJlbWFpbCI6InRpZ2VyQGFjbWUuY29tIiwiYXV0aCI6ImRHbG5aWEk2Y0dGemN6RXhNdz09In19fQ=="
    },
    "kind": "Secret",
    "metadata": {
        "creationTimestamp": "2021-07-01T07:30:59Z",
        "name": "secret-tiger-docker",
        "namespace": "default",
        "resourceVersion": "566718",
        "uid": "e15c1d7b-9071-4100-8681-f3a7a2ce89ca"
    },
    "type": "kubernetes.io/dockerconfigjson"
}

Testing

Unit tests are run with jest with ts-jest and can be found in the ./test directory

Integration tests use Minikube and are executed within workflows in ./github/workflows

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Support

k8s-create-secret is an open source project that is not covered by the Microsoft Azure support policy. Please search open issues here, and if your issue isn't already represented please open a new one. The project maintainers will respond to the best of their abilities.