Skip to content

Secret

Bases: DuploResourceV3

Kubernetes Secrets

This class provides methods to manage Kubernetes Secrets in DuploCloud.

See more details at: https://docs.duplocloud.com/docs/kubernetes-overview/configs-and-secrets/setting-kubernetes-secrets

Commands

apply

Apply a Secret

Create or Update a Secret resource with Duplocloud cli.

CLI Usage

duploctl secret apply -f 'secret.yaml'
Contents of the secret.yaml file
SecretName: duploctl
SecretType: Opaque
SecretData:
  username: admin
  password: secret123
SecretLabels:
  test: myapp
SecretAnnotations:
  something: cool

Returns:

Name Type Description
message dict

Success message.

Parameters:

--file, -f, --cli-input
A file to read the input from
FileType('r') action: YamlAction
--wait, -w
Wait for the operation to complete
--patches, --add, --remove, --copy, --replace, --test, --move
The json patch to apply
str action: JsonPatchAction

create

Create a Secret

Create a new Kubernetes secret managed through DuploCloud.

CLI Usage

duploctl secret create -f secret.yaml
Contents of the secret.yaml file
SecretName: duploctl
SecretType: Opaque
SecretData:
  username: admin
  password: secret123
SecretLabels:
  test: myapp
SecretAnnotations:
  something: cool

Create a secret using a one-liner.
echo """
SecretName: duploctl
SecretType: Opaque
SecretData:
  username: admin
  password: secret123
SecretLabels:
  test: myapp
SecretAnnotations:
  something: cool

""" | duploctl secret create -f -
Create a secret using a file.
duploctl secret create -f secret.yaml
Create a secret by specifying key-value pairs as literals.
duploctl secret create <secret-name> --from-literal Key1="Val1" --from-literal Key2="Val2"
Create a secret from a file.
duploctl secret create <secret-name> --from-file secret-map.txt

Returns:

Name Type Description
message dict

The updated secret or a success message.

Raises:

Type Description
DuploError

If the secret create fails.

Model: DuploK8Secret
{
  "description": "DuploK8Secret",
  "properties": {
    "IsDuploManaged": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Isduplomanaged"
    },
    "SecretName": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Secretname"
    },
    "SecretType": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Secrettype"
    },
    "SecretData": {
      "anyOf": [
        {
          "additionalProperties": {
            "additionalProperties": true,
            "type": "object"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Secretdata"
    },
    "SecretVersion": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Secretversion"
    },
    "SecretAnnotations": {
      "anyOf": [
        {
          "additionalProperties": {
            "type": "string"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Secretannotations"
    },
    "SecretLabels": {
      "anyOf": [
        {
          "additionalProperties": {
            "type": "string"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Secretlabels"
    },
    "SkipBase64Encoding": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Skipbase64Encoding"
    }
  },
  "title": "DuploK8Secret",
  "type": "object"
}

Parameters:

name positional
The resource name
str
--file, -f, --cli-input
A file to read the input from
DuploK8Secret action: YamlAction
--fromfile, --from-file, --from-literal
A file or literal value to add to the data map
str action: DataMapAction
--dryrun, --dry-run
Do not submit any changes to the server, just print the data to the console.

delete

Delete Secret

Deletes the specified Secret by name.

cli
duploctl secret delete <name>

Returns:

Name Type Description
message dict

Returns a success message if deleted successfully; otherwise, an error.

Parameters:

name positional
The resource name
str

find

Find a Secret.

Retrieve details of a specific kubernetes Secret by name

cli usage
duploctl secret find <name>

Returns:

Name Type Description
message dict

The resource content or success message.

Raises:

Type Description
DuploError

Secret not found.

Parameters:

name positional
The resource name
str

list

Retrieve a List of Secret resources

cli usage
duploctl secret list

Returns:

Name Type Description
list list

A list of Secret.

update

Updates a secret resource.

Updates an existing Kubernetes Secret resource with new or modified data.

CLI Usage

duploctl secret update -f secret.yaml
Contents of the secret.yaml file
SecretName: duploctl
SecretType: Opaque
SecretData:
  username: admin
  password: secret123
SecretLabels:
  test: myapp
SecretAnnotations:
  something: cool

Update secret using a one-liner.
echo """
SecretName: duploctl
SecretType: Opaque
SecretData:
  username: admin
  password: secret123
SecretLabels:
  test: myapp
SecretAnnotations:
  something: cool

""" | duploctl secret update -f -
Add new keys in the secret.
duploctl secret update <secret-name> --add /SecretData/NewKey1 NewValue1 --add /SecretData/NewKey2 NewValue2
Update existing keys from the secret.
duploctl secret update <secret-name> --replace /SecretData/ExistingKey1 NewValue1 --replace /SecretData/ExistingKey2 NewValue2
Delete existing keys from the secret.
duploctl secret update <secret-name> --remove /SecretData/ExistingKey1 --remove /SecretData/ExistingKey2
Update a secret by specifying key-value pairs as literals.
duploctl secret update <secret-name> --from-literal Key1="Val1" --from-literal Key2="Val2"
Update a secret from a file.
duploctl secret update <secret-name> --from-file secret.txt
Adds labels and annotations to an existing Secret resource.

Since annotations and labels do have dots and tildes, there is some special syntax here.

duploctl secret update <secret-name> --add /SecretLabels/my.label~0/foo NewLabelVal --add SecretAnnotations.NewAnnotation AnnotationVal

Returns:

Name Type Description
message dict

The updated secret or a success message.

Raises:

Type Description
DuploError

If the secret update fails.

Model: DuploK8Secret
{
  "description": "DuploK8Secret",
  "properties": {
    "IsDuploManaged": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Isduplomanaged"
    },
    "SecretName": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Secretname"
    },
    "SecretType": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Secrettype"
    },
    "SecretData": {
      "anyOf": [
        {
          "additionalProperties": {
            "additionalProperties": true,
            "type": "object"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Secretdata"
    },
    "SecretVersion": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Secretversion"
    },
    "SecretAnnotations": {
      "anyOf": [
        {
          "additionalProperties": {
            "type": "string"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Secretannotations"
    },
    "SecretLabels": {
      "anyOf": [
        {
          "additionalProperties": {
            "type": "string"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Secretlabels"
    },
    "SkipBase64Encoding": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Skipbase64Encoding"
    }
  },
  "title": "DuploK8Secret",
  "type": "object"
}

Parameters:

name positional
The resource name
str
--file, -f, --cli-input
A file to read the input from
DuploK8Secret action: YamlAction
--fromfile, --from-file, --from-literal
A file or literal value to add to the data map
str action: DataMapAction
--patches, --add, --remove, --copy, --replace, --test, --move
The json patch to apply
str action: JsonPatchAction
--dryrun, --dry-run
Do not submit any changes to the server, just print the data to the console.

Methods

name_from_body