diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..1326700af --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,3 @@ +{ + "image": "mcr.microsoft.com/dotnet/sdk:8.0" +} \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..841fcae61 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,37 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**Kubernetes C# SDK Client Version** +e.g. `9.0.1` + +**Server Kubernetes Version** +e.g. `1.22.3` + +**Dotnet Runtime Version** +e.g. net6 + +**To Reproduce** +Steps to reproduce the behavior: + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**KubeConfig** +If applicable, add a KubeConfig file with secrets redacted. + +**Where do you run your app with Kubernetes SDK (please complete the following information):** + - OS: [e.g. Linux] + - Environment [e.g. container] + - Cloud [e.g. Azure] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/workflows/buildtest.yaml b/.github/workflows/buildtest.yaml index c0a114796..26d585ec7 100644 --- a/.github/workflows/buildtest.yaml +++ b/.github/workflows/buildtest.yaml @@ -8,63 +8,82 @@ jobs: os: [ubuntu-latest, windows-latest, macOS-latest] name: Dotnet build steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 with: fetch-depth: 0 - - name: Setup dotnet SDK 3.1 - uses: actions/setup-dotnet@v2 + - name: Setup dotnet + uses: actions/setup-dotnet@v5 with: - dotnet-version: '3.1.x' - - name: Setup dotnet SDK 5 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: '5.0.x' - - name: Setup dotnet SDK 6 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: '6.0.x' - # - name: Check Format - # # don't check formatting on Windows b/c of CRLF issues. - # if: matrix.os == 'ubuntu-latest' - # run: dotnet format --severity error --verify-no-changes --exclude ./src/KubernetesClient/generated/ + dotnet-version: | + 8.0.x + 9.0.x - name: Build - run: dotnet build --configuration Release -v detailed + run: dotnet build --configuration Release - name: Test - run: dotnet test /p:CollectCoverage=true /p:ExcludeByFile=\"**/KubernetesClient/generated/**/*.cs\" /p:CoverletOutputFormat="cobertura" - # - uses: 5monkeys/cobertura-action@master - # with: - # path: tests/KubernetesClient.Tests/coverage.netcoreapp2.1.cobertura.xml - # repo_token: ${{ secrets.GITHUB_TOKEN }} - # minimum_coverage: 0 - e2e: - runs-on: ubuntu-latest + run: dotnet test --configuration Release --collect:"Code Coverage;Format=Cobertura" --logger trx --results-directory TestResults --settings CodeCoverage.runsettings --no-build + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v5 + with: + directory: ./TestResults + files: '*.cobertura.xml' + - name: Upload test results + uses: actions/upload-artifact@v5 + with: + name: test-results-${{ matrix.os }} + path: ./TestResults + if: ${{ always() }} # Always run this step even on failure + + # Test code gen for visual studio compatibility >> https://github.com/kubernetes-client/csharp/pull/1008 + codgen: + runs-on: windows-latest + name: MSBuild build steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 with: fetch-depth: 0 - - name: Setup dotnet SDK 3.1 - uses: actions/setup-dotnet@v2 + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v2 + - name: Setup dotnet SDK + uses: actions/setup-dotnet@v5 with: - dotnet-version: '3.1.x' - - name: Setup dotnet SDK 5 - uses: actions/setup-dotnet@v2 + dotnet-version: '9.0.x' + - name: Restore nugets (msbuild) + run: msbuild .\src\KubernetesClient\ -t:restore -p:RestorePackagesConfig=true + - name: Build (msbuild) + run: msbuild .\src\KubernetesClient\ + + e2e: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 with: - dotnet-version: '5.0.x' - - name: Setup dotnet SDK 6 - uses: actions/setup-dotnet@v2 + fetch-depth: 0 + - name: Setup dotnet + uses: actions/setup-dotnet@v5 with: - dotnet-version: '6.0.x' + dotnet-version: | + 8.0.x + 9.0.x - name: Minikube run: minikube start - name: Test run: | true > skip.log - env K8S_E2E_MINIKUBE=1 dotnet test tests/E2E.Tests --logger "SkipTestLogger;file=$PWD/skip.log" + env K8S_E2E_MINIKUBE=1 dotnet test tests/E2E.Tests --logger "SkipTestLogger;file=$PWD/skip.log" -p:BuildInParallel=false + if [ -s skip.log ]; then + cat skip.log + echo "CASES MUST NOT BE SKIPPED" + exit 1 + fi + - name: AOT Test + run: | + true > skip.log + env K8S_E2E_MINIKUBE=1 dotnet test tests/E2E.Aot.Tests --logger "SkipTestLogger;file=$PWD/skip.log" -p:BuildInParallel=false if [ -s skip.log ]; then cat skip.log echo "CASES MUST NOT BE SKIPPED" exit 1 - fi + fi on: pull_request: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 94566421d..6355396eb 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,5 +1,10 @@ name: "CodeQL" +permissions: + actions: read + contents: read + security-events: write + on: push: branches: [ master ] @@ -12,7 +17,7 @@ on: jobs: analyze: name: Analyze - runs-on: windows-2019 + runs-on: windows-2022 strategy: fail-fast: false @@ -21,26 +26,20 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v5 with: fetch-depth: 0 - - name: Setup dotnet SDK 3.1 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: '3.1.x' - - name: Setup dotnet SDK 5 - uses: actions/setup-dotnet@v2 + - name: Setup dotnet + uses: actions/setup-dotnet@v5 with: - dotnet-version: '5.0.x' - - name: Setup dotnet SDK 6 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: '6.0.x' + dotnet-version: | + 8.0.x + 9.0.x # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v4 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -48,8 +47,16 @@ jobs: # Prefix the list here with "+" to use these queries and those in the config file. # queries: ./path/to/local/query, your-org/your-repo/queries@main - - name: Autobuild - uses: github/codeql-action/autobuild@v2 + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). + # If this step fails, then you should remove it and run the build manually (see below) + # Currently .NET8.0 isn't supported + # - name: Autobuild + # uses: github/codeql-action/autobuild@v2 + + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --configuration Debug --no-restore - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v4 diff --git a/.github/workflows/docfx.yaml b/.github/workflows/docfx.yaml new file mode 100644 index 000000000..3eec06ec3 --- /dev/null +++ b/.github/workflows/docfx.yaml @@ -0,0 +1,56 @@ +name: Docfx + +on: + push: + branches: [ master ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow one concurrent deployment +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + docfx: + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Setup dotnet + uses: actions/setup-dotnet@v5 + with: + dotnet-version: | + 8.0.x + 9.0.x + + - name: Build + run: dotnet build -c Release + + - uses: nunit/docfx-action@v4.1.0 + name: Build Documentation + with: + args: doc/docfx.json + + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Upload artifact + uses: actions/upload-pages-artifact@v4 + with: + # Upload entire repository + path: doc/_site + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/draft.yaml b/.github/workflows/draft.yaml index 1a143fe0f..01b098518 100644 --- a/.github/workflows/draft.yaml +++ b/.github/workflows/draft.yaml @@ -1,5 +1,8 @@ name: Draft Release +permissions: + contents: write + on: push: branches: [ master ] @@ -10,24 +13,16 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 with: fetch-depth: 0 - - name: .NET Core 3.1.x SDK - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 3.1.x - - - name: .NET 5.x SDK - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 5.0.x - - - name: .NET 6.x SDK - uses: actions/setup-dotnet@v2 + - name: Setup dotnet + uses: actions/setup-dotnet@v5 with: - dotnet-version: 6.0.x + dotnet-version: | + 8.0.x + 9.0.x - name: dotnet restore run: dotnet restore --verbosity minimal --configfile nuget.config @@ -44,4 +39,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh release create -d --generate-notes v$env:NBGV_NuGetPackageVersion \ No newline at end of file + gh release create -d --generate-notes v$env:NBGV_NuGetPackageVersion diff --git a/.github/workflows/nuget.yaml b/.github/workflows/nuget.yaml index a39cd63e4..fa654822f 100644 --- a/.github/workflows/nuget.yaml +++ b/.github/workflows/nuget.yaml @@ -10,24 +10,16 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 with: fetch-depth: 0 - - name: .NET Core 3.1.x SDK - uses: actions/setup-dotnet@v2 + - name: Setup dotnet + uses: actions/setup-dotnet@v5 with: - dotnet-version: 3.1.x - - - name: .NET 5.x SDK - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 5.0.x - - - name: .NET 6.x SDK - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 6.0.x + dotnet-version: | + 8.0.x + 9.0.x - name: dotnet restore run: dotnet restore --verbosity minimal --configfile nuget.config @@ -52,17 +44,17 @@ jobs: matrix: nuget-package: - "KubernetesClient" - - "KubernetesClient.Models" - - "KubernetesClient.Basic" - "KubernetesClient.Classic" runs-on: ubuntu-latest + permissions: + packages: write steps: - name: Delete old NuGet packages - uses: actions/delete-package-versions@v3 + uses: actions/delete-package-versions@v5 with: owner: ${{ env.GITHUB_REPOSITORY_OWNER }} - repo: ${{ github.event.repository.name }} token: ${{ secrets.GITHUB_TOKEN }} package-name: ${{ matrix.nuget-package }} + package-type: nuget min-versions-to-keep: 10 diff --git a/.gitignore b/.gitignore index d24a2eae2..46bc886d3 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,6 @@ bin/ *.sln.iml launchSettings.json -*.DotSettings \ No newline at end of file +*.DotSettings + +*.sln \ No newline at end of file diff --git a/CodeCoverage.runsettings b/CodeCoverage.runsettings new file mode 100644 index 000000000..acc025c10 --- /dev/null +++ b/CodeCoverage.runsettings @@ -0,0 +1,40 @@ + + + + + + + + + + .*KubernetesClient\..*\.dll$ + + + .*tests\.dll$ + .*xunit.*dll$ + .*moq\.dll$ + .*System\.Reactive\.dll$ + .*BouncyCastle\.Crypto\.dll$ + .*IdentityModel\.OidcClient\.dll$ + + + + True + + True + + True + + + ^System.ObsoleteAttribute$ + ^System.CodeDom.Compiler.GeneratedCodeAttribute$ + ^System.Diagnostics.DebuggerHiddenAttribute$ + ^System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute$ + + + + + + + + diff --git a/Directory.Build.props b/Directory.Build.props index 6af780d70..3d3e1cfce 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,4 +1,4 @@ - + $(MSBuildThisFileDirectory)\kubernetes-client.ruleset @@ -26,7 +26,7 @@ snupkg true $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - 10.0 + 13.0 diff --git a/Directory.Build.targets b/Directory.Build.targets index 001ec93f7..517121e49 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,12 +1,5 @@ - - - - - - - - - - + + + diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 000000000..27783a77c --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,54 @@ + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 3a060c888..c8eb91626 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,23 @@ # Kubernetes C# Client -[![Travis](https://img.shields.io/travis/kubernetes-client/csharp.svg)](https://travis-ci.org/kubernetes-client/csharp) + +[![Github Actions Build](https://github.com/kubernetes-client/csharp/actions/workflows/buildtest.yaml/badge.svg)](https://github.com/kubernetes-client/csharp/actions/workflows/buildtest.yaml) [![Client Capabilities](https://img.shields.io/badge/Kubernetes%20client-Silver-blue.svg?style=flat&colorB=C0C0C0&colorA=306CE8)](http://bit.ly/kubernetes-client-capabilities-badge) [![Client Support Level](https://img.shields.io/badge/kubernetes%20client-beta-green.svg?style=flat&colorA=306CE8)](http://bit.ly/kubernetes-client-support-badge) # Usage -[Nuget Package](https://www.nuget.org/packages/KubernetesClient/) + +[![KubernetesClient](https://img.shields.io/nuget/v/KubernetesClient)](https://www.nuget.org/packages/KubernetesClient/) ```sh dotnet add package KubernetesClient ``` +## Generate with Visual Studio + +``` +dotnet msbuild /Restore /t:SlnGen kubernetes-client.proj +``` + ## Authentication/Configuration You should be able to use a standard KubeConfig file with this library, see the `BuildConfigFromConfigFile` function below. Most authentication @@ -20,14 +28,11 @@ You should also be able to authenticate with the in-cluster service account using the `InClusterConfig` function shown below. ## Monitoring -There is optional built-in metric generation for prometheus client metrics. -The exported metrics are: - -* `k8s_dotnet_request_total` - Counter of request, broken down by HTTP Method -* `k8s_dotnet_response_code_total` - Counter of responses, broken down by HTTP Method and response code -* `k8s_request_latency_seconds` - Latency histograms broken down by method, api group, api version and resource kind +Metrics are built in to HttpClient using System.Diagnostics.DiagnosticsSource. +https://learn.microsoft.com/en-us/dotnet/core/diagnostics/built-in-metrics-system-net -There is an example integrating these monitors in the examples/prometheus directory. +There are many ways these metrics can be consumed/exposed but that decision is up to the application, not KubernetesClient itself. +https://learn.microsoft.com/en-us/dotnet/core/diagnostics/metrics-collection ## Sample Code @@ -96,7 +101,7 @@ var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); var client = new Kubernetes(config); ``` -Not all auth providers are supported at moment [#91](https://github.com/kubernetes-client/csharp/issues/91#issuecomment-362920478). You can still connect to a cluster by starting the proxy command: +Not all auth providers are supported at the moment [#91](https://github.com/kubernetes-client/csharp/issues/91#issuecomment-362920478). You can still connect to a cluster by starting the proxy command: ```bash $ kubectl proxy @@ -147,24 +152,42 @@ ${GEN_DIR}/openapi/csharp.sh ${REPO_DIR}/src/KubernetesClient ${REPO_DIR}/csharp # Version Compatibility -| SDK Version | Kubernetes Version | .NET Targeting | -|-------------|--------------------|------------------------------------------------------| -| 9.0 | 1.25 | netstandard2.1;net5.0;net6.0;net48*;netstandard2.0* | -| 8.0 | 1.24 | netstandard2.1;net5.0;net6.0;net48*;netstandard2.0* | -| 7.2 | 1.23 | netstandard2.1;net5.0;net6.0;net48*;netstandard2.0* | -| 7.0 | 1.23 | netstandard2.1;net5.0;net6.0 | -| 6.0 | 1.22 | netstandard2.1;net5.0 | -| 5.0 | 1.21 | netstandard2.1;net5 | -| 4.0 | 1.20 | netstandard2.0;netstandard2.1 | -| 3.0 | 1.19 | netstandard2.0;net452 | -| 2.0 | 1.18 | netstandard2.0;net452 | -| 1.6 | 1.16 | netstandard1.4;netstandard2.0;net452; | -| 1.4 | 1.13 | netstandard1.4;net451 | -| 1.3 | 1.12 | netstandard1.4;net452 | +| SDK Version | Kubernetes Version | .NET Targeting | +|-------------|--------------------|-----------------------------------------------------| +| 18.0 | 1.34 | net8.0;net9.0;net48*;netstandard2.0* | +| 17.0 | 1.33 | net8.0;net9.0;net48*;netstandard2.0* | +| 16.0 | 1.32 | net8.0;net9.0;net48*;netstandard2.0* | +| 15.0 | 1.31 | net6.0;net8.0;net48*;netstandard2.0* | +| 14.0 | 1.30 | net6.0;net8.0;net48*;netstandard2.0* | +| 13.0 | 1.29 | net6.0;net7.0;net8.0;net48*;netstandard2.0* | +| 12.0 | 1.28 | net6.0;net7.0;net48*;netstandard2.0* | +| 11.0 | 1.27 | net6.0;net7.0;net48*;netstandard2.0* | +| 10.0 | 1.26 | net6.0;net7.0;net48*;netstandard2.0* | +| 9.1 | 1.25 | netstandard2.1;net6.0;net7.0;net48*;netstandard2.0* | +| 9.0 | 1.25 | netstandard2.1;net5.0;net6.0;net48*;netstandard2.0* | +| 8.0 | 1.24 | netstandard2.1;net5.0;net6.0;net48*;netstandard2.0* | +| 7.2 | 1.23 | netstandard2.1;net5.0;net6.0;net48*;netstandard2.0* | +| 7.0 | 1.23 | netstandard2.1;net5.0;net6.0 | +| 6.0 | 1.22 | netstandard2.1;net5.0 | +| 5.0 | 1.21 | netstandard2.1;net5 | +| 4.0 | 1.20 | netstandard2.0;netstandard2.1 | +| 3.0 | 1.19 | netstandard2.0;net452 | +| 2.0 | 1.18 | netstandard2.0;net452 | +| 1.6 | 1.16 | netstandard1.4;netstandard2.0;net452; | +| 1.4 | 1.13 | netstandard1.4;net451 | +| 1.3 | 1.12 | netstandard1.4;net452 | * Starting from `2.0`, [dotnet sdk versioning](https://github.com/kubernetes-client/csharp/issues/400) adopted * `Kubernetes Version` here means the version sdk models and apis were generated from - * Kubernetes api server guarantees the compatibility with `n-2` version. for exmaple, 1.19 based sdk should work with 1.21 cluster, but no guarantee works with 1.22 cluster. see also + * Kubernetes api server guarantees the compatibility with `n-2` (`n-3` after 1.28) version. for example: + - 1.19 based sdk should work with 1.21 cluster, but not guaranteed to work with 1.22 cluster.
+ + and vice versa: + - 1.21 based sdk should work with 1.19 cluster, but not guaranteed to work with 1.18 cluster.
+Note: in practice, the sdk might work with much older clusters, at least for the more stable functionality. However, it is not guaranteed past the `n-2` (or `n-3` after 1.28 ) version. See [#1511](https://github.com/kubernetes-client/csharp/issues/1511) for additional details.
+ + see also + * Fixes (including security fixes) are not back-ported automatically to older sdk versions. However, contributions from the community are welcomed 😊; See [Contributing](#contributing) for instructions on how to contribute. * `*` `KubernetesClient.Classic`: netstandard2.0 and net48 are supported with limited features diff --git a/SECURITY_CONTACTS b/SECURITY_CONTACTS index d22538052..df0df1c5f 100644 --- a/SECURITY_CONTACTS +++ b/SECURITY_CONTACTS @@ -11,3 +11,4 @@ # INSTRUCTIONS AT https://kubernetes.io/security/ brendandburns +tg123 diff --git a/csharp.settings b/csharp.settings index 6d67b355a..0110958c8 100644 --- a/csharp.settings +++ b/csharp.settings @@ -1,3 +1,3 @@ -export KUBERNETES_BRANCH=v1.25.0 +export KUBERNETES_BRANCH=v1.34.0 export CLIENT_VERSION=0.0.1 export PACKAGE_NAME=k8s diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 000000000..2f16432e9 --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1,11 @@ +############### +# folder # +############### +/**/DROP/ +/**/TEMP/ +/**/packages/ +/**/bin/ +/**/obj/ +_site + +api \ No newline at end of file diff --git a/doc/CONTRIBUTING.md b/doc/CONTRIBUTING.md new file mode 120000 index 000000000..44fcc6343 --- /dev/null +++ b/doc/CONTRIBUTING.md @@ -0,0 +1 @@ +../CONTRIBUTING.md \ No newline at end of file diff --git a/doc/docfx.json b/doc/docfx.json new file mode 100644 index 000000000..2917802e6 --- /dev/null +++ b/doc/docfx.json @@ -0,0 +1,41 @@ +{ + "metadata": [ + { + "src": [ + { + "files": [ + "KubernetesClient/bin/Release/net8.0/KubernetesClient.dll" + ], + "src": "../src" + } + ], + "dest": "api", + "disableGitFeatures": false, + "disableDefaultFilter": false + } + ], + "build": { + "content": [ + { + "files": [ + "api/**.yml", + "index.md", + "CONTRIBUTING.md", + "toc.yml" + ] + } + ], + "dest": "_site", + "globalMetadataFiles": [], + "fileMetadataFiles": [], + "template": [ + "default" + ], + "postProcessors": [], + "markdownEngineName": "markdig", + "noLangKeyword": false, + "keepFileLink": false, + "cleanupCacheHistory": false, + "disableGitFeatures": false + } +} \ No newline at end of file diff --git a/doc/index.md b/doc/index.md new file mode 120000 index 000000000..32d46ee88 --- /dev/null +++ b/doc/index.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file diff --git a/doc/toc.yml b/doc/toc.yml new file mode 100644 index 000000000..8bf2c8ed1 --- /dev/null +++ b/doc/toc.yml @@ -0,0 +1,2 @@ +- name: API Documentation + href: api/k8s.yml diff --git a/examples/Directory.Build.props b/examples/Directory.Build.props index ab4d8e735..b87fe6aaa 100644 --- a/examples/Directory.Build.props +++ b/examples/Directory.Build.props @@ -1,6 +1,7 @@ + - net6.0 + net9.0 diff --git a/examples/Directory.Build.targets b/examples/Directory.Build.targets index 3b7810177..bf5f5ee49 100644 --- a/examples/Directory.Build.targets +++ b/examples/Directory.Build.targets @@ -1,5 +1,6 @@ + - + diff --git a/examples/GenericKubernetesApi/Program.cs b/examples/GenericKubernetesApi/Program.cs deleted file mode 100644 index 5a093fad1..000000000 --- a/examples/GenericKubernetesApi/Program.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Threading; -using System.Threading.Tasks; -using k8s; -using k8s.Models; -using k8s.Util.Common; -using k8s.Util.Common.Generic; - -namespace GenericKubernetesApiExample -{ - public class Program - { - private static GenericKubernetesApi _genericKubernetesApi; - - public static void Main(string[] args) - { - var config = KubernetesClientConfiguration.BuildDefaultConfig(); - IKubernetes client = new Kubernetes(config); - var cts = new CancellationTokenSource(); - - _genericKubernetesApi = new GenericKubernetesApi( - apiGroup: "pod", - apiVersion: "v1", - resourcePlural: "pods", - apiClient: client); - - var aPod = GetNamespacedPod(Namespaces.NamespaceDefault, "my-pod-name", cts.Token); - var aListOfPods = ListPodsInNamespace(Namespaces.NamespaceDefault, cts.Token); - - // Watch for pod actions in a namespsace - using var watch = _genericKubernetesApi.Watch( - Namespaces.NamespaceDefault, - (eventType, pod) => { Console.WriteLine("The event {0} happened on pod named {1}", eventType, pod.Metadata.Name); }, - exception => { Console.WriteLine("Oh no! An exception happened while watching pods. The message was '{0}'.", exception.Message); }, - () => { Console.WriteLine("The server closed the connection."); }); - - Console.WriteLine("press ctrl + c to stop watching"); - - var ctrlc = new ManualResetEventSlim(false); - Console.CancelKeyPress += (sender, eventArgs) => ctrlc.Set(); - ctrlc.Wait(); - cts.Cancel(); - } - - private static V1Pod GetNamespacedPod(string @namespace, string podName, CancellationToken cancellationToken) - { - var resp = Task.Run( - async () => await _genericKubernetesApi.GetAsync(@namespace, podName, cancellationToken).ConfigureAwait(false), cancellationToken); - - return resp.Result; - } - - private static V1PodList ListPodsInNamespace(string @namespace, CancellationToken cancellationToken) - { - var resp = Task.Run( - async () => await _genericKubernetesApi.ListAsync(@namespace, cancellationToken).ConfigureAwait(false), cancellationToken); - - return resp.Result; - } - } -} diff --git a/examples/aks-kubelogin/Program.cs b/examples/aks-kubelogin/Program.cs new file mode 100644 index 000000000..cdee0cf10 --- /dev/null +++ b/examples/aks-kubelogin/Program.cs @@ -0,0 +1,49 @@ +using k8s; +using System; +using System.IO; +using System.Text; + +var server = "https://example.hcp.eastus.azmk8s.io/"; // the server url of your aks +var clientid = "00000000-0000-0000-0000-000000000000"; // the client id of the your msi +var kubelogin = @"C:\bin\kubelogin.exe"; // the path to the kubelogin.exe + +using var configstream = new MemoryStream(Encoding.ASCII.GetBytes($""" +apiVersion: v1 +clusters: +- cluster: + insecure-skip-tls-verify: true + server: {server} + name: aks +contexts: +- context: + cluster: aks + user: msi + name: aks +current-context: aks +kind: Config +users: +- name: msi + user: + exec: + apiVersion: client.authentication.k8s.io/v1beta1 + args: + - get-token + - --login + - msi + - --server-id + - 6dae42f8-4368-4678-94ff-3960e28e3630 + - --client-id + - {clientid} + command: {kubelogin} + env: null +""")); + +var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(configstream); +IKubernetes client = new Kubernetes(config); +Console.WriteLine("Starting Request!"); + +var list = client.CoreV1.ListNamespacedPod("default"); +foreach (var item in list.Items) +{ + Console.WriteLine(item.Metadata.Name); +} diff --git a/examples/aks-kubelogin/README.md b/examples/aks-kubelogin/README.md new file mode 100644 index 000000000..ab71071b0 --- /dev/null +++ b/examples/aks-kubelogin/README.md @@ -0,0 +1,24 @@ +# AKS C# example using kubelogin + MSI + +This example shows how to use the [kubelogin](https://github.com/Azure/kubelogin) to authenticate using [managed identities](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/overview) with Azure Kubernetes Service (AKS) using the C# SDK. + + +## Prerequisites + + - turn on AAD support for AKS, see [here](https://docs.microsoft.com/en-us/azure/aks/managed-aad) + - create a managed identity for the AKS cluster + - assign the managed identity the `Azure Kubernetes Service RBAC Cluster Admin` (or other RBAC permission) on the AKS cluster + - assign the managed identity to the VM, see [here](https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/qs-configure-portal-windows-vm) + - install the [kubelogin](https://github.com/Azure/kubelogin) to your machine + +## Running the code + + *You must the the code on VM with MSI* + + - Replace `server` with the address of your AKS cluster + - Replace `clientid` with the client id of the managed identity + - Replace `kubelogin` with the path to the kubelogin executable + +``` +dotnet run +``` \ No newline at end of file diff --git a/examples/GenericKubernetesApi/GenericKubernetesApi.csproj b/examples/aks-kubelogin/aks-kubelogin.csproj similarity index 89% rename from examples/GenericKubernetesApi/GenericKubernetesApi.csproj rename to examples/aks-kubelogin/aks-kubelogin.csproj index 139aaf588..11afe8d56 100644 --- a/examples/GenericKubernetesApi/GenericKubernetesApi.csproj +++ b/examples/aks-kubelogin/aks-kubelogin.csproj @@ -1,7 +1,5 @@ - Exe - - +
\ No newline at end of file diff --git a/examples/aot/Program.cs b/examples/aot/Program.cs new file mode 100644 index 000000000..d5125c0ff --- /dev/null +++ b/examples/aot/Program.cs @@ -0,0 +1,16 @@ +using k8s; + +var config = KubernetesClientConfiguration.BuildDefaultConfig(); +IKubernetes client = new Kubernetes(config); +Console.WriteLine("Starting Request!"); + +var list = client.CoreV1.ListNamespacedPod("default"); +foreach (var item in list.Items) +{ + Console.WriteLine(item.Metadata.Name); +} + +if (list.Items.Count == 0) +{ + Console.WriteLine("Empty!"); +} \ No newline at end of file diff --git a/examples/aot/aot.csproj b/examples/aot/aot.csproj new file mode 100644 index 000000000..28741906d --- /dev/null +++ b/examples/aot/aot.csproj @@ -0,0 +1,11 @@ + + + Exe + enable + enable + true + + + + + diff --git a/examples/attach/Attach.cs b/examples/attach/Attach.cs index a53b5da56..cfdce7d8e 100755 --- a/examples/attach/Attach.cs +++ b/examples/attach/Attach.cs @@ -3,38 +3,29 @@ using System; using System.Threading.Tasks; -namespace attach -{ - internal class Attach - { - private static async Task Main(string[] args) - { - var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); - IKubernetes client = new Kubernetes(config); - Console.WriteLine("Starting Request!"); +var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); +IKubernetes client = new Kubernetes(config); +Console.WriteLine("Starting Request!"); - var list = client.CoreV1.ListNamespacedPod("default"); - var pod = list.Items[0]; - await AttachToPod(client, pod).ConfigureAwait(false); - } +var list = client.CoreV1.ListNamespacedPod("default"); +var pod = list.Items[0]; +await AttachToPod(client, pod).ConfigureAwait(false); - private static async Task AttachToPod(IKubernetes client, V1Pod pod) - { - var webSocket = - await client.WebSocketNamespacedPodAttachAsync(pod.Metadata.Name, "default", - pod.Spec.Containers[0].Name).ConfigureAwait(false); +async Task AttachToPod(IKubernetes client, V1Pod pod) +{ + var webSocket = + await client.WebSocketNamespacedPodAttachAsync(pod.Metadata.Name, "default", + pod.Spec.Containers[0].Name).ConfigureAwait(false); - var demux = new StreamDemuxer(webSocket); - demux.Start(); + var demux = new StreamDemuxer(webSocket); + demux.Start(); - var buff = new byte[4096]; - var stream = demux.GetStream(1, 1); - while (true) - { - var read = stream.Read(buff, 0, 4096); - var str = System.Text.Encoding.Default.GetString(buff); - Console.WriteLine(str); - } - } + var buff = new byte[4096]; + var stream = demux.GetStream(1, 1); + while (true) + { + var read = stream.Read(buff, 0, 4096); + var str = System.Text.Encoding.Default.GetString(buff); + Console.WriteLine(str); } } diff --git a/examples/clientset/Program.cs b/examples/clientset/Program.cs new file mode 100644 index 000000000..a1b74e0f8 --- /dev/null +++ b/examples/clientset/Program.cs @@ -0,0 +1,32 @@ +using k8s; +using k8s.Models; +using k8s.ClientSets; +using System.Threading.Tasks; + +namespace clientset +{ + internal class Program + { + private static async Task Main(string[] args) + { + var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); + var client = new Kubernetes(config); + + var clientSet = new ClientSet(client); + var list = await clientSet.CoreV1.Pod.ListAsync("default").ConfigureAwait(false); + foreach (var item in list) + { + System.Console.WriteLine(item.Metadata.Name); + } + + var pod = await clientSet.CoreV1.Pod.GetAsync("test", "default").ConfigureAwait(false); + System.Console.WriteLine(pod?.Metadata?.Name); + + var watch = clientSet.CoreV1.Pod.WatchListAsync("default"); + await foreach (var (_, item) in watch.ConfigureAwait(false)) + { + System.Console.WriteLine(item.Metadata.Name); + } + } + } +} \ No newline at end of file diff --git a/examples/clientset/clientset.csproj b/examples/clientset/clientset.csproj new file mode 100644 index 000000000..4274ceb02 --- /dev/null +++ b/examples/clientset/clientset.csproj @@ -0,0 +1,6 @@ + + + Exe + + + diff --git a/examples/cp/Cp.cs b/examples/cp/Cp.cs index b7dd5b207..43e769490 100644 --- a/examples/cp/Cp.cs +++ b/examples/cp/Cp.cs @@ -1,4 +1,4 @@ -using ICSharpCode.SharpZipLib.Tar; +using ICSharpCode.SharpZipLib.Tar; using k8s; using System; using System.IO; @@ -7,110 +7,104 @@ using System.Threading; using System.Threading.Tasks; -namespace cp -{ - internal class Cp - { - private static IKubernetes client; +namespace cp; - private static async Task Main(string[] args) - { - var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); - client = new Kubernetes(config); +internal class Cp +{ + private static IKubernetes client; + private static async Task Main(string[] args) + { + var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); + client = new Kubernetes(config); - var pods = client.CoreV1.ListNamespacedPod("default", null, null, null, $"job-name=upload-demo"); - var pod = pods.Items.First(); - await CopyFileToPodAsync(pod.Metadata.Name, "default", "upload-demo", args[0], $"home/{args[1]}"); + var pods = client.CoreV1.ListNamespacedPod("default", null, null, null, $"job-name=upload-demo"); + var pod = pods.Items.First(); - } + await CopyFileToPodAsync(pod.Metadata.Name, "default", "upload-demo", args[0], $"home/{args[1]}").ConfigureAwait(false); + } - private static void ValidatePathParameters(string sourcePath, string destinationPath) + private static void ValidatePathParameters(string sourcePath, string destinationPath) + { + if (string.IsNullOrWhiteSpace(sourcePath)) { - if (string.IsNullOrWhiteSpace(sourcePath)) - { - throw new ArgumentException($"{nameof(sourcePath)} cannot be null or whitespace"); - } - - if (string.IsNullOrWhiteSpace(destinationPath)) - { - throw new ArgumentException($"{nameof(destinationPath)} cannot be null or whitespace"); - } - + throw new ArgumentException($"{nameof(sourcePath)} cannot be null or whitespace"); } - public static async Task CopyFileToPodAsync(string name, string @namespace, string container, string sourceFilePath, string destinationFilePath, CancellationToken cancellationToken = default(CancellationToken)) + if (string.IsNullOrWhiteSpace(destinationPath)) { - // All other parameters are being validated by MuxedStreamNamespacedPodExecAsync called by NamespacedPodExecAsync - ValidatePathParameters(sourceFilePath, destinationFilePath); + throw new ArgumentException($"{nameof(destinationPath)} cannot be null or whitespace"); + } + } + + public static async Task CopyFileToPodAsync(string name, string @namespace, string container, string sourceFilePath, string destinationFilePath, CancellationToken cancellationToken = default(CancellationToken)) + { + // All other parameters are being validated by MuxedStreamNamespacedPodExecAsync called by NamespacedPodExecAsync + ValidatePathParameters(sourceFilePath, destinationFilePath); - // The callback which processes the standard input, standard output and standard error of exec method - var handler = new ExecAsyncCallback(async (stdIn, stdOut, stdError) => + // The callback which processes the standard input, standard output and standard error of exec method + var handler = new ExecAsyncCallback(async (stdIn, stdOut, stdError) => + { + var fileInfo = new FileInfo(destinationFilePath); + try { - var fileInfo = new FileInfo(destinationFilePath); - try + using (var memoryStream = new MemoryStream()) { - using (var memoryStream = new MemoryStream()) + using (var inputFileStream = File.OpenRead(sourceFilePath)) + using (var tarOutputStream = new TarOutputStream(memoryStream, Encoding.Default)) { - using (var inputFileStream = File.OpenRead(sourceFilePath)) - using (var tarOutputStream = new TarOutputStream(memoryStream, Encoding.Default)) - { - tarOutputStream.IsStreamOwner = false; - - var fileSize = inputFileStream.Length; - var entry = TarEntry.CreateTarEntry(fileInfo.Name); - - entry.Size = fileSize; + tarOutputStream.IsStreamOwner = false; - tarOutputStream.PutNextEntry(entry); - await inputFileStream.CopyToAsync(tarOutputStream); - tarOutputStream.CloseEntry(); - } + var fileSize = inputFileStream.Length; + var entry = TarEntry.CreateTarEntry(fileInfo.Name); - memoryStream.Position = 0; + entry.Size = fileSize; - await memoryStream.CopyToAsync(stdIn); - await stdIn.FlushAsync(); + tarOutputStream.PutNextEntry(entry); + await inputFileStream.CopyToAsync(tarOutputStream).ConfigureAwait(false); + tarOutputStream.CloseEntry(); } - } - catch (Exception ex) - { - throw new IOException($"Copy command failed: {ex.Message}"); - } + memoryStream.Position = 0; - using StreamReader streamReader = new StreamReader(stdError); - while (streamReader.EndOfStream == false) - { - string error = await streamReader.ReadToEndAsync(); - throw new IOException($"Copy command failed: {error}"); + await memoryStream.CopyToAsync(stdIn).ConfigureAwait(false); + await stdIn.FlushAsync().ConfigureAwait(false); } - }); - - string destinationFolder = GetFolderName(destinationFilePath); - - return await client.NamespacedPodExecAsync( - name, - @namespace, - container, - new string[] { "sh", "-c", $"tar xmf - -C {destinationFolder}" }, - false, - handler, - cancellationToken); - } - + } + catch (Exception ex) + { + throw new IOException($"Copy command failed: {ex.Message}"); + } - private static string GetFolderName(string filePath) - { - var folderName = Path.GetDirectoryName(filePath); + using StreamReader streamReader = new StreamReader(stdError); + while (streamReader.EndOfStream == false) + { + string error = await streamReader.ReadToEndAsync().ConfigureAwait(false); + throw new IOException($"Copy command failed: {error}"); + } + }); + + string destinationFolder = GetFolderName(destinationFilePath); + + return await client.NamespacedPodExecAsync( + name, + @namespace, + container, + new string[] { "sh", "-c", $"tar xmf - -C {destinationFolder}" }, + false, + handler, + cancellationToken).ConfigureAwait(false); + } - return string.IsNullOrEmpty(folderName) ? "." : folderName; - } + private static string GetFolderName(string filePath) + { + var folderName = Path.GetDirectoryName(filePath); + return string.IsNullOrEmpty(folderName) ? "." : folderName; } } diff --git a/examples/cp/cp.csproj b/examples/cp/cp.csproj index 27cff0379..cde0f0fca 100644 --- a/examples/cp/cp.csproj +++ b/examples/cp/cp.csproj @@ -5,7 +5,7 @@ - + diff --git a/examples/csrApproval/Program.cs b/examples/csrApproval/Program.cs index b4f154864..6c374105b 100644 --- a/examples/csrApproval/Program.cs +++ b/examples/csrApproval/Program.cs @@ -1,4 +1,4 @@ -using Json.Patch; +using Json.Patch; using k8s; using k8s.Models; using System.Net; @@ -21,7 +21,7 @@ string GenerateCertificate(string name) var request = new CertificateRequest(distinguishedName, rsa, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1); request.CertificateExtensions.Add(new X509KeyUsageExtension(X509KeyUsageFlags.DataEncipherment | X509KeyUsageFlags.KeyEncipherment | X509KeyUsageFlags.DigitalSignature, false)); - request.CertificateExtensions.Add(new X509EnhancedKeyUsageExtension(new OidCollection { new("1.3.6.1.5.5.7.3.1") }, false)); + request.CertificateExtensions.Add(new X509EnhancedKeyUsageExtension([new ("1.3.6.1.5.5.7.3.1")], false)); request.CertificateExtensions.Add(sanBuilder.Build()); var csr = request.CreateSigningRequest(); var pemKey = "-----BEGIN CERTIFICATE REQUEST-----\r\n" + @@ -44,34 +44,42 @@ string GenerateCertificate(string name) Kind = "CertificateSigningRequest", Metadata = new V1ObjectMeta { - Name = name + Name = name, }, Spec = new V1CertificateSigningRequestSpec { Request = encodedCsr, SignerName = "kubernetes.io/kube-apiserver-client", Usages = new List { "client auth" }, - ExpirationSeconds = 600 // minimum should be 10 minutes - } + ExpirationSeconds = 600, // minimum should be 10 minutes + }, }; -await client.CertificatesV1.CreateCertificateSigningRequestAsync(request); +await client.CertificatesV1.CreateCertificateSigningRequestAsync(request).ConfigureAwait(false); var serializeOptions = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, - WriteIndented = true + WriteIndented = true, }; -var readCert = await client.CertificatesV1.ReadCertificateSigningRequestAsync(name); +var readCert = await client.CertificatesV1.ReadCertificateSigningRequestAsync(name).ConfigureAwait(false); var old = JsonSerializer.SerializeToDocument(readCert, serializeOptions); var replace = new List { - new("True", "Approved", DateTime.UtcNow, DateTime.UtcNow, "This certificate was approved by k8s client", "Approve") + new V1CertificateSigningRequestCondition + { + Type = "Approved", + Status = "True", + Reason = "Approve", + Message = "This certificate was approved by k8s client", + LastUpdateTime = DateTime.UtcNow, + LastTransitionTime = DateTime.UtcNow, + }, }; readCert.Status.Conditions = replace; var expected = JsonSerializer.SerializeToDocument(readCert, serializeOptions); var patch = old.CreatePatch(expected); -await client.CertificatesV1.PatchCertificateSigningRequestApprovalAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), name); +await client.CertificatesV1.PatchCertificateSigningRequestApprovalAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), name).ConfigureAwait(false); diff --git a/examples/csrApproval/csrApproval.csproj b/examples/csrApproval/csrApproval.csproj index 51531b474..f67de4fbc 100644 --- a/examples/csrApproval/csrApproval.csproj +++ b/examples/csrApproval/csrApproval.csproj @@ -7,6 +7,6 @@ - + diff --git a/examples/customResource/CustomResourceDefinition.cs b/examples/customResource/CustomResourceDefinition.cs index b0deb2913..ad1b7f9c4 100644 --- a/examples/customResource/CustomResourceDefinition.cs +++ b/examples/customResource/CustomResourceDefinition.cs @@ -32,8 +32,8 @@ public abstract class CustomResource : CustomResource [JsonPropertyName("spec")] public TSpec Spec { get; set; } - [JsonPropertyName("CStatus")] - public TStatus CStatus { get; set; } + [JsonPropertyName("status")] + public TStatus Status { get; set; } } public class CustomResourceList : KubernetesObject diff --git a/examples/customResource/Program.cs b/examples/customResource/Program.cs index 3898f3134..726852a7f 100644 --- a/examples/customResource/Program.cs +++ b/examples/customResource/Program.cs @@ -92,11 +92,11 @@ private static async Task Main(string[] args) // deleting the custom resource try { - myCr = await generic.DeleteNamespacedAsync( + var status = await generic.DeleteNamespacedAsync( myCr.Metadata.NamespaceProperty ?? "default", myCr.Metadata.Name).ConfigureAwait(false); - Console.WriteLine("Deleted the CR"); + Console.WriteLine($"Deleted the CR status: {status}"); } catch (Exception exception) { diff --git a/examples/customResource/cResource.cs b/examples/customResource/cResource.cs index f9df60b22..67440aee9 100644 --- a/examples/customResource/cResource.cs +++ b/examples/customResource/cResource.cs @@ -19,13 +19,13 @@ public override string ToString() } } - public class CResourceSpec + public record CResourceSpec { [JsonPropertyName("cityName")] public string CityName { get; set; } } - public class CResourceStatus : V1Status + public record CResourceStatus : V1Status { [JsonPropertyName("temperature")] public string Temperature { get; set; } diff --git a/examples/customResource/customResource.csproj b/examples/customResource/customResource.csproj index c20c0a210..ad2bdd739 100644 --- a/examples/customResource/customResource.csproj +++ b/examples/customResource/customResource.csproj @@ -5,7 +5,7 @@ - + diff --git a/examples/exec/Exec.cs b/examples/exec/Exec.cs index 9fdfc73b0..20bbd2125 100755 --- a/examples/exec/Exec.cs +++ b/examples/exec/Exec.cs @@ -3,35 +3,26 @@ using System; using System.Threading.Tasks; -namespace exec -{ - internal class Exec - { - private static async Task Main(string[] args) - { - var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); - IKubernetes client = new Kubernetes(config); - Console.WriteLine("Starting Request!"); +var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); +IKubernetes client = new Kubernetes(config); +Console.WriteLine("Starting Request!"); - var list = client.CoreV1.ListNamespacedPod("default"); - var pod = list.Items[0]; - await ExecInPod(client, pod).ConfigureAwait(false); - } +var list = client.CoreV1.ListNamespacedPod("default"); +var pod = list.Items[0]; +await ExecInPod(client, pod).ConfigureAwait(false); - private static async Task ExecInPod(IKubernetes client, V1Pod pod) - { - var webSocket = - await client.WebSocketNamespacedPodExecAsync(pod.Metadata.Name, "default", "ls", - pod.Spec.Containers[0].Name).ConfigureAwait(false); +async Task ExecInPod(IKubernetes client, V1Pod pod) +{ + var webSocket = + await client.WebSocketNamespacedPodExecAsync(pod.Metadata.Name, "default", "ls", + pod.Spec.Containers[0].Name).ConfigureAwait(false); - var demux = new StreamDemuxer(webSocket); - demux.Start(); + var demux = new StreamDemuxer(webSocket); + demux.Start(); - var buff = new byte[4096]; - var stream = demux.GetStream(1, 1); - var read = stream.Read(buff, 0, 4096); - var str = System.Text.Encoding.Default.GetString(buff); - Console.WriteLine(str); - } - } + var buff = new byte[4096]; + var stream = demux.GetStream(1, 1); + var read = stream.Read(buff, 0, 4096); + var str = System.Text.Encoding.Default.GetString(buff); + Console.WriteLine(str); } diff --git a/examples/generic/Generic.cs b/examples/generic/Generic.cs index 41f91b39f..f65fb944d 100644 --- a/examples/generic/Generic.cs +++ b/examples/generic/Generic.cs @@ -1,26 +1,16 @@ using k8s; using k8s.Models; using System; -using System.Threading.Tasks; -namespace exec -{ - internal class Generic - { - private static async Task Main(string[] args) - { - var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); - IKubernetes client = new Kubernetes(config); - var generic = new GenericClient(client, "", "v1", "nodes"); - var node = await generic.ReadAsync("kube0").ConfigureAwait(false); - Console.WriteLine(node.Metadata.Name); +var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); +IKubernetes client = new Kubernetes(config); +var generic = new GenericClient(client, "", "v1", "nodes"); +var node = await generic.ReadAsync("kube0").ConfigureAwait(false); +Console.WriteLine(node.Metadata.Name); - var genericPods = new GenericClient(client, "", "v1", "pods"); - var pods = await genericPods.ListNamespacedAsync("default").ConfigureAwait(false); - foreach (var pod in pods.Items) - { - Console.WriteLine(pod.Metadata.Name); - } - } - } +var genericPods = new GenericClient(client, "", "v1", "pods"); +var pods = await genericPods.ListNamespacedAsync("default").ConfigureAwait(false); +foreach (var pod in pods.Items) +{ + Console.WriteLine(pod.Metadata.Name); } diff --git a/examples/labels/PodList.cs b/examples/labels/PodList.cs index 2d59e9026..0c5df001d 100755 --- a/examples/labels/PodList.cs +++ b/examples/labels/PodList.cs @@ -2,47 +2,38 @@ using System; using System.Collections.Generic; -namespace simple +var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); +IKubernetes client = new Kubernetes(config); +Console.WriteLine("Starting Request!"); + +var list = client.CoreV1.ListNamespacedService("default"); +foreach (var item in list.Items) { - internal class PodList + Console.WriteLine("Pods for service: " + item.Metadata.Name); + Console.WriteLine("=-=-=-=-=-=-=-=-=-=-="); + if (item.Spec == null || item.Spec.Selector == null) { - private static void Main(string[] args) - { - var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); - IKubernetes client = new Kubernetes(config); - Console.WriteLine("Starting Request!"); - - var list = client.CoreV1.ListNamespacedService("default"); - foreach (var item in list.Items) - { - Console.WriteLine("Pods for service: " + item.Metadata.Name); - Console.WriteLine("=-=-=-=-=-=-=-=-=-=-="); - if (item.Spec == null || item.Spec.Selector == null) - { - continue; - } - - var labels = new List(); - foreach (var key in item.Spec.Selector) - { - labels.Add(key.Key + "=" + key.Value); - } + continue; + } - var labelStr = string.Join(",", labels.ToArray()); - Console.WriteLine(labelStr); - var podList = client.CoreV1.ListNamespacedPod("default", labelSelector: labelStr); - foreach (var pod in podList.Items) - { - Console.WriteLine(pod.Metadata.Name); - } + var labels = new List(); + foreach (var key in item.Spec.Selector) + { + labels.Add(key.Key + "=" + key.Value); + } - if (podList.Items.Count == 0) - { - Console.WriteLine("Empty!"); - } + var labelStr = string.Join(",", labels.ToArray()); + Console.WriteLine(labelStr); + var podList = client.CoreV1.ListNamespacedPod("default", labelSelector: labelStr); + foreach (var pod in podList.Items) + { + Console.WriteLine(pod.Metadata.Name); + } - Console.WriteLine(); - } - } + if (podList.Items.Count == 0) + { + Console.WriteLine("Empty!"); } + + Console.WriteLine(); } diff --git a/examples/logs/Logs.cs b/examples/logs/Logs.cs index ea23fa05f..5293de579 100755 --- a/examples/logs/Logs.cs +++ b/examples/logs/Logs.cs @@ -1,31 +1,21 @@ using k8s; using System; -using System.Threading.Tasks; -namespace logs -{ - internal class Logs - { - private static async Task Main(string[] args) - { - var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); - IKubernetes client = new Kubernetes(config); - Console.WriteLine("Starting Request!"); +var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); +IKubernetes client = new Kubernetes(config); +Console.WriteLine("Starting Request!"); - var list = client.CoreV1.ListNamespacedPod("default"); - if (list.Items.Count == 0) - { - Console.WriteLine("No pods!"); - return; - } +var list = client.CoreV1.ListNamespacedPod("default"); +if (list.Items.Count == 0) +{ + Console.WriteLine("No pods!"); + return; +} - var pod = list.Items[0]; +var pod = list.Items[0]; - var response = await client.CoreV1.ReadNamespacedPodLogWithHttpMessagesAsync( - pod.Metadata.Name, - pod.Metadata.NamespaceProperty, container: pod.Spec.Containers[0].Name, follow: true).ConfigureAwait(false); - var stream = response.Body; - stream.CopyTo(Console.OpenStandardOutput()); - } - } -} +var response = await client.CoreV1.ReadNamespacedPodLogWithHttpMessagesAsync( + pod.Metadata.Name, + pod.Metadata.NamespaceProperty, container: pod.Spec.Containers[0].Name, follow: true).ConfigureAwait(false); +var stream = response.Body; +stream.CopyTo(Console.OpenStandardOutput()); diff --git a/examples/metrics/Program.cs b/examples/metrics/Program.cs index 33a779f09..f823bf54d 100644 --- a/examples/metrics/Program.cs +++ b/examples/metrics/Program.cs @@ -3,58 +3,49 @@ using System.Linq; using System.Threading.Tasks; -namespace metrics +async Task NodesMetrics(IKubernetes client) { - internal class Program + var nodesMetrics = await client.GetKubernetesNodesMetricsAsync().ConfigureAwait(false); + + foreach (var item in nodesMetrics.Items) { - private static async Task NodesMetrics(IKubernetes client) + Console.WriteLine(item.Metadata.Name); + + foreach (var metric in item.Usage) { - var nodesMetrics = await client.GetKubernetesNodesMetricsAsync().ConfigureAwait(false); + Console.WriteLine($"{metric.Key}: {metric.Value}"); + } + } +} - foreach (var item in nodesMetrics.Items) - { - Console.WriteLine(item.Metadata.Name); +async Task PodsMetrics(IKubernetes client) +{ + var podsMetrics = await client.GetKubernetesPodsMetricsAsync().ConfigureAwait(false); - foreach (var metric in item.Usage) - { - Console.WriteLine($"{metric.Key}: {metric.Value}"); - } - } - } + if (!podsMetrics.Items.Any()) + { + Console.WriteLine("Empty"); + } - private static async Task PodsMetrics(IKubernetes client) + foreach (var item in podsMetrics.Items) + { + foreach (var container in item.Containers) { - var podsMetrics = await client.GetKubernetesPodsMetricsAsync().ConfigureAwait(false); - - if (!podsMetrics.Items.Any()) - { - Console.WriteLine("Empty"); - } + Console.WriteLine(container.Name); - foreach (var item in podsMetrics.Items) + foreach (var metric in container.Usage) { - foreach (var container in item.Containers) - { - Console.WriteLine(container.Name); - - foreach (var metric in container.Usage) - { - Console.WriteLine($"{metric.Key}: {metric.Value}"); - } - } - - Console.Write(Environment.NewLine); + Console.WriteLine($"{metric.Key}: {metric.Value}"); } } - private static async Task Main(string[] args) - { - var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); - var client = new Kubernetes(config); - - await NodesMetrics(client).ConfigureAwait(false); - Console.WriteLine(Environment.NewLine); - await PodsMetrics(client).ConfigureAwait(false); - } + Console.Write(Environment.NewLine); } } + +var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); +var client = new Kubernetes(config); + +await NodesMetrics(client).ConfigureAwait(false); +Console.WriteLine(Environment.NewLine); +await PodsMetrics(client).ConfigureAwait(false); diff --git a/examples/namespace/NamespaceExample.cs b/examples/namespace/NamespaceExample.cs index 351453a4d..06e8757a4 100644 --- a/examples/namespace/NamespaceExample.cs +++ b/examples/namespace/NamespaceExample.cs @@ -4,52 +4,37 @@ using System.Net; using System.Threading.Tasks; -namespace @namespace +void ListNamespaces(IKubernetes client) { - internal class NamespaceExample + var list = client.CoreV1.ListNamespace(); + foreach (var item in list.Items) { - private static void ListNamespaces(IKubernetes client) - { - var list = client.CoreV1.ListNamespace(); - foreach (var item in list.Items) - { - Console.WriteLine(item.Metadata.Name); - } + Console.WriteLine(item.Metadata.Name); + } - if (list.Items.Count == 0) - { - Console.WriteLine("Empty!"); - } - } + if (list.Items.Count == 0) + { + Console.WriteLine("Empty!"); + } +} - private static async Task DeleteAsync(IKubernetes client, string name, int delayMillis) +async Task DeleteAsync(IKubernetes client, string name, int delayMillis) +{ + while (true) + { + await Task.Delay(delayMillis).ConfigureAwait(false); + try { - while (true) + await client.CoreV1.ReadNamespaceAsync(name).ConfigureAwait(false); + } + catch (AggregateException ex) + { + foreach (var innerEx in ex.InnerExceptions) { - await Task.Delay(delayMillis).ConfigureAwait(false); - try - { - await client.CoreV1.ReadNamespaceAsync(name).ConfigureAwait(false); - } - catch (AggregateException ex) - { - foreach (var innerEx in ex.InnerExceptions) - { - if (innerEx is k8s.Autorest.HttpOperationException) - { - var code = ((k8s.Autorest.HttpOperationException)innerEx).Response.StatusCode; - if (code == HttpStatusCode.NotFound) - { - return; - } - - throw; - } - } - } - catch (k8s.Autorest.HttpOperationException ex) + if (innerEx is k8s.Autorest.HttpOperationException exception) { - if (ex.Response.StatusCode == HttpStatusCode.NotFound) + var code = exception.Response.StatusCode; + if (code == HttpStatusCode.NotFound) { return; } @@ -58,41 +43,47 @@ private static async Task DeleteAsync(IKubernetes client, string name, int delay } } } - - private static void Delete(IKubernetes client, string name, int delayMillis) + catch (k8s.Autorest.HttpOperationException ex) { - DeleteAsync(client, name, delayMillis).Wait(); + if (ex.Response.StatusCode == HttpStatusCode.NotFound) + { + return; + } + + throw; } + } +} - private static void Main(string[] args) - { - var k8SClientConfig = KubernetesClientConfiguration.BuildConfigFromConfigFile(); - IKubernetes client = new Kubernetes(k8SClientConfig); +void Delete(IKubernetes client, string name, int delayMillis) +{ + DeleteAsync(client, name, delayMillis).Wait(); +} - ListNamespaces(client); +var k8SClientConfig = KubernetesClientConfiguration.BuildConfigFromConfigFile(); +IKubernetes client = new Kubernetes(k8SClientConfig); - var ns = new V1Namespace { Metadata = new V1ObjectMeta { Name = "test" } }; +ListNamespaces(client); - var result = client.CoreV1.CreateNamespace(ns); - Console.WriteLine(result); +var ns = new V1Namespace { Metadata = new V1ObjectMeta { Name = "test" } }; - ListNamespaces(client); +var result = client.CoreV1.CreateNamespace(ns); +Console.WriteLine(result); - var status = client.CoreV1.DeleteNamespace(ns.Metadata.Name, new V1DeleteOptions()); +ListNamespaces(client); - if (status.HasObject) - { - var obj = status.ObjectView(); - Console.WriteLine(obj.Status.Phase); +var status = client.CoreV1.DeleteNamespace(ns.Metadata.Name, new V1DeleteOptions()); - Delete(client, ns.Metadata.Name, 3 * 1000); - } - else - { - Console.WriteLine(status.Message); - } +if (status.HasObject) +{ + var obj = status.ObjectView(); + Console.WriteLine(obj.Status.Phase); - ListNamespaces(client); - } - } + Delete(client, ns.Metadata.Name, 3 * 1000); } +else +{ + Console.WriteLine(status.Message); +} + +ListNamespaces(client); diff --git a/examples/openTelemetryConsole/Program.cs b/examples/openTelemetryConsole/Program.cs index 9a5460dcb..4b7406be3 100644 --- a/examples/openTelemetryConsole/Program.cs +++ b/examples/openTelemetryConsole/Program.cs @@ -24,11 +24,12 @@ // Read the list of pods contained in default namespace var list = client.CoreV1.ListNamespacedPod("default"); -// Print the name of pods +// Print the name of pods foreach (var item in list.Items) { Console.WriteLine(item.Metadata.Name); } + // Or empty if there are no pods if (list.Items.Count == 0) { diff --git a/examples/openTelemetryConsole/openTelemetryConsole.csproj b/examples/openTelemetryConsole/openTelemetryConsole.csproj index 374da9c72..ff48d4450 100644 --- a/examples/openTelemetryConsole/openTelemetryConsole.csproj +++ b/examples/openTelemetryConsole/openTelemetryConsole.csproj @@ -7,9 +7,8 @@ - - - + + diff --git a/examples/patch-aot/Program.cs b/examples/patch-aot/Program.cs new file mode 100644 index 000000000..e72f6a4d2 --- /dev/null +++ b/examples/patch-aot/Program.cs @@ -0,0 +1,33 @@ +using k8s; +using k8s.Models; + +var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); +IKubernetes client = new Kubernetes(config); +Console.WriteLine("Starting Request!"); + +var pod = client.CoreV1.ListNamespacedPod("default").Items.First(); +var name = pod.Metadata.Name; +PrintLabels(pod); + +var patchStr = @" +{ + ""metadata"": { + ""labels"": { + ""test"": ""test"" + } + } +}"; + +client.CoreV1.PatchNamespacedPod(new V1Patch(patchStr, V1Patch.PatchType.MergePatch), name, "default"); +PrintLabels(client.CoreV1.ReadNamespacedPod(name, "default")); + +static void PrintLabels(V1Pod pod) +{ + Console.WriteLine($"Labels: for {pod.Metadata.Name}"); + foreach (var (k, v) in pod.Metadata.Labels) + { + Console.WriteLine($"{k} : {v}"); + } + + Console.WriteLine("=-=-=-=-=-=-=-=-=-=-="); +} diff --git a/examples/patch-aot/patch-aot.csproj b/examples/patch-aot/patch-aot.csproj new file mode 100644 index 000000000..c2c806215 --- /dev/null +++ b/examples/patch-aot/patch-aot.csproj @@ -0,0 +1,11 @@ + + + Exe + enable + enable + true + + + + + diff --git a/examples/patch/Program.cs b/examples/patch/Program.cs index 7958fcc35..f8cefa67c 100644 --- a/examples/patch/Program.cs +++ b/examples/patch/Program.cs @@ -3,21 +3,15 @@ using System; using System.Linq; -namespace patch -{ - internal class Program - { - private static void Main(string[] args) - { - var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); - IKubernetes client = new Kubernetes(config); - Console.WriteLine("Starting Request!"); +var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); +IKubernetes client = new Kubernetes(config); +Console.WriteLine("Starting Request!"); - var pod = client.CoreV1.ListNamespacedPod("default").Items.First(); - var name = pod.Metadata.Name; - PrintLabels(pod); +var pod = client.CoreV1.ListNamespacedPod("default").Items.First(); +var name = pod.Metadata.Name; +PrintLabels(pod); - var patchStr = @" +var patchStr = @" { ""metadata"": { ""labels"": { @@ -26,19 +20,16 @@ private static void Main(string[] args) } }"; - client.CoreV1.PatchNamespacedPod(new V1Patch(patchStr, V1Patch.PatchType.MergePatch), name, "default"); - PrintLabels(client.CoreV1.ReadNamespacedPod(name, "default")); - } - - private static void PrintLabels(V1Pod pod) - { - Console.WriteLine($"Labels: for {pod.Metadata.Name}"); - foreach (var (k, v) in pod.Metadata.Labels) - { - Console.WriteLine($"{k} : {v}"); - } +client.CoreV1.PatchNamespacedPod(new V1Patch(patchStr, V1Patch.PatchType.MergePatch), name, "default"); +PrintLabels(client.CoreV1.ReadNamespacedPod(name, "default")); - Console.WriteLine("=-=-=-=-=-=-=-=-=-=-="); - } +void PrintLabels(V1Pod pod) +{ + Console.WriteLine($"Labels: for {pod.Metadata.Name}"); + foreach (var (k, v) in pod.Metadata.Labels) + { + Console.WriteLine($"{k} : {v}"); } + + Console.WriteLine("=-=-=-=-=-=-=-=-=-=-="); } diff --git a/examples/portforward/PortForward.cs b/examples/portforward/PortForward.cs index fe9485d86..ee095e073 100644 --- a/examples/portforward/PortForward.cs +++ b/examples/portforward/PortForward.cs @@ -6,74 +6,66 @@ using System.Text; using System.Threading.Tasks; -namespace portforward -{ - internal class Portforward - { - private static async Task Main(string[] args) - { - var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); - IKubernetes client = new Kubernetes(config); - Console.WriteLine("Starting port forward!"); +var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); +IKubernetes client = new Kubernetes(config); +Console.WriteLine("Starting port forward!"); - var list = client.CoreV1.ListNamespacedPod("default"); - var pod = list.Items[0]; - await Forward(client, pod); - } - - private static async Task Forward(IKubernetes client, V1Pod pod) - { - // Note this is single-threaded, it won't handle concurrent requests well... - var webSocket = await client.WebSocketNamespacedPodPortForwardAsync(pod.Metadata.Name, "default", new int[] { 80 }, "v4.channel.k8s.io"); - var demux = new StreamDemuxer(webSocket, StreamType.PortForward); - demux.Start(); +var list = client.CoreV1.ListNamespacedPod("default"); +var pod = list.Items[0]; +await Forward(client, pod).ConfigureAwait(false); - var stream = demux.GetStream((byte?)0, (byte?)0); +async Task Forward(IKubernetes client, V1Pod pod) +{ + // Note this is single-threaded, it won't handle concurrent requests well... + var webSocket = await client.WebSocketNamespacedPodPortForwardAsync(pod.Metadata.Name, "default", new int[] { 80 }, "v4.channel.k8s.io").ConfigureAwait(false); + var demux = new StreamDemuxer(webSocket, StreamType.PortForward); + demux.Start(); - IPAddress ipAddress = IPAddress.Loopback; - IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 8080); - Socket listener = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp); - listener.Bind(localEndPoint); - listener.Listen(100); + var stream = demux.GetStream((byte?)0, (byte?)0); - Socket handler = null; + IPAddress ipAddress = IPAddress.Loopback; + IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 8080); + Socket listener = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp); + listener.Bind(localEndPoint); + listener.Listen(100); - // Note this will only accept a single connection - var accept = Task.Run(() => - { - while (true) - { - handler = listener.Accept(); - var bytes = new byte[4096]; - while (true) - { - int bytesRec = handler.Receive(bytes); - stream.Write(bytes, 0, bytesRec); - if (bytesRec == 0 || Encoding.ASCII.GetString(bytes, 0, bytesRec).IndexOf("") > -1) - { - break; - } - } - } - }); + Socket handler = null; - var copy = Task.Run(() => + // Note this will only accept a single connection + var accept = Task.Run(() => + { + while (true) + { + handler = listener.Accept(); + var bytes = new byte[4096]; + while (true) { - var buff = new byte[4096]; - while (true) + int bytesRec = handler.Receive(bytes); + stream.Write(bytes, 0, bytesRec); + if (bytesRec == 0 || Encoding.ASCII.GetString(bytes, 0, bytesRec).IndexOf("") > -1) { - var read = stream.Read(buff, 0, 4096); - handler.Send(buff, read, 0); + break; } - }); - - await accept; - await copy; - if (handler != null) - { - handler.Close(); } - listener.Close(); } + }); + + var copy = Task.Run(() => + { + var buff = new byte[4096]; + while (true) + { + var read = stream.Read(buff, 0, 4096); + handler.Send(buff, read, 0); + } + }); + + await accept.ConfigureAwait(false); + await copy.ConfigureAwait(false); + if (handler != null) + { + handler.Close(); } + + listener.Close(); } diff --git a/examples/prometheus/Prometheus.cs b/examples/prometheus/Prometheus.cs deleted file mode 100755 index 0a3111ef7..000000000 --- a/examples/prometheus/Prometheus.cs +++ /dev/null @@ -1,31 +0,0 @@ -using k8s; -using k8s.Monitoring; -using Prometheus; -using System; -using System.Net.Http; -using System.Threading; - -namespace prom -{ - internal class Prometheus - { - private static void Main(string[] args) - { - var config = KubernetesClientConfiguration.BuildDefaultConfig(); - var handler = new PrometheusHandler(); - IKubernetes client = new Kubernetes(config, new DelegatingHandler[] { handler }); - - var server = new MetricServer(hostname: "localhost", port: 1234); - server.Start(); - - Console.WriteLine("Making requests!"); - while (true) - { - client.CoreV1.ListNamespacedPod("default"); - client.CoreV1.ListNode(); - client.AppsV1.ListNamespacedDeployment("default"); - Thread.Sleep(1000); - } - } - } -} diff --git a/examples/resize/Program.cs b/examples/resize/Program.cs new file mode 100644 index 000000000..85fbeb9b2 --- /dev/null +++ b/examples/resize/Program.cs @@ -0,0 +1,63 @@ +using k8s; +using k8s.Models; +using System; +using System.Collections.Generic; + + +var config = KubernetesClientConfiguration.BuildDefaultConfig(); +var client = new Kubernetes(config); + + +var pod = new V1Pod +{ + Metadata = new V1ObjectMeta { Name = "nginx-pod" }, + Spec = new V1PodSpec + { + Containers = + [ + new V1Container + { + Name = "nginx", + Image = "nginx", + Resources = new V1ResourceRequirements + { + Requests = new Dictionary() + { + ["cpu"] = "100m", + }, + }, + }, + ], + }, +}; +{ + var created = await client.CoreV1.CreateNamespacedPodAsync(pod, "default").ConfigureAwait(false); + Console.WriteLine($"Created pod: {created.Metadata.Name}"); +} + +{ + var patchStr = @" + { + ""spec"": { + ""containers"": [ + { + ""name"": ""nginx"", + ""resources"": { + ""requests"": { + ""cpu"": ""200m"" + } + } + } + ] + } + }"; + + var patch = await client.CoreV1.PatchNamespacedPodResizeAsync(new V1Patch(patchStr, V1Patch.PatchType.MergePatch), "nginx-pod", "default").ConfigureAwait(false); + + if (patch?.Spec?.Containers?.Count > 0 && + patch.Spec.Containers[0].Resources?.Requests != null && + patch.Spec.Containers[0].Resources.Requests.TryGetValue("cpu", out var cpuQty)) + { + Console.WriteLine($"CPU request: {cpuQty}"); + } +} diff --git a/examples/prometheus/prometheus.csproj b/examples/resize/resize.csproj old mode 100755 new mode 100644 similarity index 88% rename from examples/prometheus/prometheus.csproj rename to examples/resize/resize.csproj index 52e6553de..d1e5b4724 --- a/examples/prometheus/prometheus.csproj +++ b/examples/resize/resize.csproj @@ -1,7 +1,5 @@ - Exe - - + \ No newline at end of file diff --git a/examples/restart/Program.cs b/examples/restart/Program.cs index b6e7a6f22..894e305a6 100644 --- a/examples/restart/Program.cs +++ b/examples/restart/Program.cs @@ -1,17 +1,17 @@ -using Json.Patch; +using Json.Patch; using k8s; using k8s.Models; using System.Text.Json; async Task RestartDaemonSetAsync(string name, string @namespace, IKubernetes client) { - var daemonSet = await client.AppsV1.ReadNamespacedDaemonSetAsync(name, @namespace); + var daemonSet = await client.AppsV1.ReadNamespacedDaemonSetAsync(name, @namespace).ConfigureAwait(false); var options = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, WriteIndented = true }; var old = JsonSerializer.SerializeToDocument(daemonSet, options); var now = DateTimeOffset.Now.ToUnixTimeSeconds(); var restart = new Dictionary { - ["date"] = now.ToString() + ["date"] = now.ToString(), }; daemonSet.Spec.Template.Metadata.Annotations = restart; @@ -19,18 +19,18 @@ async Task RestartDaemonSetAsync(string name, string @namespace, IKubernetes cli var expected = JsonSerializer.SerializeToDocument(daemonSet); var patch = old.CreatePatch(expected); - await client.AppsV1.PatchNamespacedDaemonSetAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), name, @namespace); + await client.AppsV1.PatchNamespacedDaemonSetAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), name, @namespace).ConfigureAwait(false); } async Task RestartDeploymentAsync(string name, string @namespace, IKubernetes client) { - var deployment = await client.AppsV1.ReadNamespacedDeploymentAsync(name, @namespace); + var deployment = await client.AppsV1.ReadNamespacedDeploymentAsync(name, @namespace).ConfigureAwait(false); var options = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, WriteIndented = true }; var old = JsonSerializer.SerializeToDocument(deployment, options); var now = DateTimeOffset.Now.ToUnixTimeSeconds(); var restart = new Dictionary { - ["date"] = now.ToString() + ["date"] = now.ToString(), }; deployment.Spec.Template.Metadata.Annotations = restart; @@ -38,18 +38,18 @@ async Task RestartDeploymentAsync(string name, string @namespace, IKubernetes cl var expected = JsonSerializer.SerializeToDocument(deployment); var patch = old.CreatePatch(expected); - await client.AppsV1.PatchNamespacedDeploymentAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), name, @namespace); + await client.AppsV1.PatchNamespacedDeploymentAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), name, @namespace).ConfigureAwait(false); } async Task RestartStatefulSetAsync(string name, string @namespace, IKubernetes client) { - var deployment = await client.AppsV1.ReadNamespacedStatefulSetAsync(name, @namespace); + var deployment = await client.AppsV1.ReadNamespacedStatefulSetAsync(name, @namespace).ConfigureAwait(false); var options = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, WriteIndented = true }; var old = JsonSerializer.SerializeToDocument(deployment, options); var now = DateTimeOffset.Now.ToUnixTimeSeconds(); var restart = new Dictionary { - ["date"] = now.ToString() + ["date"] = now.ToString(), }; deployment.Spec.Template.Metadata.Annotations = restart; @@ -57,12 +57,12 @@ async Task RestartStatefulSetAsync(string name, string @namespace, IKubernetes c var expected = JsonSerializer.SerializeToDocument(deployment); var patch = old.CreatePatch(expected); - await client.AppsV1.PatchNamespacedStatefulSetAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), name, @namespace); + await client.AppsV1.PatchNamespacedStatefulSetAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), name, @namespace).ConfigureAwait(false); } var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); IKubernetes client = new Kubernetes(config); -await RestartDeploymentAsync("event-exporter", "monitoring", client); -await RestartDaemonSetAsync("prometheus-exporter", "monitoring", client); -await RestartStatefulSetAsync("argocd-application-controlle", "argocd", client); +await RestartDeploymentAsync("event-exporter", "monitoring", client).ConfigureAwait(false); +await RestartDaemonSetAsync("prometheus-exporter", "monitoring", client).ConfigureAwait(false); +await RestartStatefulSetAsync("argocd-application-controlle", "argocd", client).ConfigureAwait(false); diff --git a/examples/restart/restart.csproj b/examples/restart/restart.csproj index 9adb54279..0d5a49c4c 100644 --- a/examples/restart/restart.csproj +++ b/examples/restart/restart.csproj @@ -7,7 +7,7 @@ - + diff --git a/examples/simple/PodList.cs b/examples/simple/PodList.cs index b9eb3cdcf..751622c16 100755 --- a/examples/simple/PodList.cs +++ b/examples/simple/PodList.cs @@ -1,26 +1,17 @@ using k8s; using System; -namespace simple -{ - internal class PodList - { - private static void Main(string[] args) - { - var config = KubernetesClientConfiguration.BuildDefaultConfig(); - IKubernetes client = new Kubernetes(config); - Console.WriteLine("Starting Request!"); +var config = KubernetesClientConfiguration.BuildDefaultConfig(); +IKubernetes client = new Kubernetes(config); +Console.WriteLine("Starting Request!"); - var list = client.CoreV1.ListNamespacedPod("default"); - foreach (var item in list.Items) - { - Console.WriteLine(item.Metadata.Name); - } +var list = client.CoreV1.ListNamespacedPod("default"); +foreach (var item in list.Items) +{ + Console.WriteLine(item.Metadata.Name); +} - if (list.Items.Count == 0) - { - Console.WriteLine("Empty!"); - } - } - } +if (list.Items.Count == 0) +{ + Console.WriteLine("Empty!"); } diff --git a/examples/watch/Program.cs b/examples/watch/Program.cs index 525cbec5c..1aff65883 100644 --- a/examples/watch/Program.cs +++ b/examples/watch/Program.cs @@ -1,50 +1,39 @@ using k8s; -using k8s.Models; using System; using System.Threading; using System.Threading.Tasks; -namespace watch -{ - internal class Program - { - private static async Task Main(string[] args) - { - var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); +var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); - IKubernetes client = new Kubernetes(config); +IKubernetes client = new Kubernetes(config); - var podlistResp = client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", watch: true); - // C# 8 required https://docs.microsoft.com/en-us/archive/msdn-magazine/2019/november/csharp-iterating-with-async-enumerables-in-csharp-8 - await foreach (var (type, item) in podlistResp.WatchAsync()) - { - Console.WriteLine("==on watch event=="); - Console.WriteLine(type); - Console.WriteLine(item.Metadata.Name); - Console.WriteLine("==on watch event=="); - } +var podlistResp = client.CoreV1.WatchListNamespacedPodAsync("default"); - // uncomment if you prefer callback api - // WatchUsingCallback(client); - } +// C# 8 required https://docs.microsoft.com/en-us/archive/msdn-magazine/2019/november/csharp-iterating-with-async-enumerables-in-csharp-8 +await foreach (var (type, item) in podlistResp.ConfigureAwait(false)) +{ + Console.WriteLine("==on watch event=="); + Console.WriteLine(type); + Console.WriteLine(item.Metadata.Name); + Console.WriteLine("==on watch event=="); +} - private static void WatchUsingCallback(IKubernetes client) - { - var podlistResp = client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", watch: true); - using (podlistResp.Watch((type, item) => - { - Console.WriteLine("==on watch event=="); - Console.WriteLine(type); - Console.WriteLine(item.Metadata.Name); - Console.WriteLine("==on watch event=="); - })) - { - Console.WriteLine("press ctrl + c to stop watching"); +#pragma warning disable CS8321 // Remove unused private members +void WatchUsingCallback(IKubernetes client) +#pragma warning restore CS8321 // Remove unused private members +{ + using (var podlistResp = client.CoreV1.WatchListNamespacedPod("default", onEvent: (type, item) => + { + Console.WriteLine("==on watch event=="); + Console.WriteLine(type); + Console.WriteLine(item.Metadata.Name); + Console.WriteLine("==on watch event=="); + })) + { + Console.WriteLine("press ctrl + c to stop watching"); - var ctrlc = new ManualResetEventSlim(false); - Console.CancelKeyPress += (sender, eventArgs) => ctrlc.Set(); - ctrlc.Wait(); - } - } + var ctrlc = new ManualResetEventSlim(false); + Console.CancelKeyPress += (sender, eventArgs) => ctrlc.Set(); + ctrlc.Wait(); } -} +} \ No newline at end of file diff --git a/examples/webApiDependencyInjection/Controllers/ExampleDependencyInjectionOnConstructorController.cs b/examples/webApiDependencyInjection/Controllers/ExampleDependencyInjectionOnConstructorController.cs index 30fd2656c..6bff6df0d 100644 --- a/examples/webApiDependencyInjection/Controllers/ExampleDependencyInjectionOnConstructorController.cs +++ b/examples/webApiDependencyInjection/Controllers/ExampleDependencyInjectionOnConstructorController.cs @@ -10,22 +10,23 @@ public class ExampleDependencyInjectionOnConstructorController : ControllerBase private readonly IKubernetes kubernetesClient; /// - /// Inject the kubernets class in the constructor. + /// Initializes a new instance of the class. + /// Injects the Kubernetes client into the controller. /// - /// + /// The Kubernetes client to interact with the Kubernetes API. public ExampleDependencyInjectionOnConstructorController(IKubernetes kubernetesClient) { this.kubernetesClient = kubernetesClient; } /// - /// Example using the kubernetes client obtained from the constructor (this.kubernetesClient). + /// Retrieves the names of all pods in the default namespace using the injected Kubernetes client. /// - /// - [HttpGet()] + /// A collection of pod names in the default namespace. + [HttpGet] public IEnumerable GetPods() { - // Read the list of pods contained in default namespace + // Read the list of pods contained in the default namespace var podList = this.kubernetesClient.CoreV1.ListNamespacedPod("default"); // Return names of pods diff --git a/examples/webApiDependencyInjection/Controllers/ExampleDependencyInjectionOnMethodController.cs b/examples/webApiDependencyInjection/Controllers/ExampleDependencyInjectionOnMethodController.cs index 0a831befb..84427f5e2 100644 --- a/examples/webApiDependencyInjection/Controllers/ExampleDependencyInjectionOnMethodController.cs +++ b/examples/webApiDependencyInjection/Controllers/ExampleDependencyInjectionOnMethodController.cs @@ -10,11 +10,13 @@ public class ExampleDependencyInjectionOnMethodController : ControllerBase /// /// Example using the kubernetes client injected directly into the method ([FromServices] IKubernetes kubernetesClient). /// - /// - /// - [HttpGet()] + /// The Kubernetes client instance injected via dependency injection. + /// A collection of pod names in the default namespace. + [HttpGet] public IEnumerable GetPods([FromServices] IKubernetes kubernetesClient) { + ArgumentNullException.ThrowIfNull(kubernetesClient); + // Read the list of pods contained in default namespace var podList = kubernetesClient.CoreV1.ListNamespacedPod("default"); diff --git a/examples/webApiDependencyInjection/webApiDependencyInjection.csproj b/examples/webApiDependencyInjection/webApiDependencyInjection.csproj index 43064ecb1..23e466d7e 100644 --- a/examples/webApiDependencyInjection/webApiDependencyInjection.csproj +++ b/examples/webApiDependencyInjection/webApiDependencyInjection.csproj @@ -6,7 +6,7 @@ - + diff --git a/examples/workerServiceDependencyInjection/Program.cs b/examples/workerServiceDependencyInjection/Program.cs index 59bf3cf25..a894a33fe 100644 --- a/examples/workerServiceDependencyInjection/Program.cs +++ b/examples/workerServiceDependencyInjection/Program.cs @@ -14,4 +14,4 @@ }) .Build(); -await host.RunAsync(); +await host.RunAsync().ConfigureAwait(false); diff --git a/examples/workerServiceDependencyInjection/Worker.cs b/examples/workerServiceDependencyInjection/Worker.cs index 87d2ecfe2..cb2f82386 100644 --- a/examples/workerServiceDependencyInjection/Worker.cs +++ b/examples/workerServiceDependencyInjection/Worker.cs @@ -8,10 +8,11 @@ public class Worker : BackgroundService private readonly IKubernetes kubernetesClient; /// + /// Initializes a new instance of the class. /// Inject in the constructor the IKubernetes interface. /// - /// - /// + /// The logger instance used for logging information. + /// The Kubernetes client used to interact with the Kubernetes API. public Worker(ILogger logger, IKubernetes kubernetesClient) { this.logger = logger; @@ -33,7 +34,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) Console.WriteLine(pod.Metadata.Name); } - await Task.Delay(1000, stoppingToken); + await Task.Delay(1000, stoppingToken).ConfigureAwait(false); } } } diff --git a/examples/workerServiceDependencyInjection/workerServiceDependencyInjection.csproj b/examples/workerServiceDependencyInjection/workerServiceDependencyInjection.csproj index accf7dd56..84522ab7c 100644 --- a/examples/workerServiceDependencyInjection/workerServiceDependencyInjection.csproj +++ b/examples/workerServiceDependencyInjection/workerServiceDependencyInjection.csproj @@ -6,6 +6,6 @@ - + diff --git a/examples/yaml/Program.cs b/examples/yaml/Program.cs index a724f3083..47b70bdfe 100644 --- a/examples/yaml/Program.cs +++ b/examples/yaml/Program.cs @@ -2,25 +2,17 @@ using k8s.Models; using System; using System.Collections.Generic; -using System.Threading.Tasks; -namespace yaml +var typeMap = new Dictionary { - internal class Program - { - private static async Task Main(string[] args) - { - var typeMap = new Dictionary(); - typeMap.Add("v1/Pod", typeof(V1Pod)); - typeMap.Add("v1/Service", typeof(V1Service)); - typeMap.Add("apps/v1/Deployment", typeof(V1Deployment)); + { "v1/Pod", typeof(V1Pod) }, + { "v1/Service", typeof(V1Service) }, + { "apps/v1/Deployment", typeof(V1Deployment) }, +}; - var objects = await KubernetesYaml.LoadAllFromFileAsync(args[0], typeMap); +var objects = await KubernetesYaml.LoadAllFromFileAsync(args[0], typeMap).ConfigureAwait(false); - foreach (var obj in objects) - { - Console.WriteLine(obj); - } - } - } +foreach (var obj in objects) +{ + Console.WriteLine(obj); } diff --git a/global.json b/global.json index ed66463ef..101665708 100644 --- a/global.json +++ b/global.json @@ -1,10 +1,9 @@ - { - "sdk": { - "version": "6.0.400", - "rollForward": "latestMajor" - }, - "msbuild-sdks": { - "Microsoft.Build.Traversal" : "3.1.6" - } + "sdk": { + "version": "8.0.100", + "rollForward": "latestMajor" + }, + "msbuild-sdks": { + "Microsoft.Build.Traversal": "4.1.0" + } } diff --git a/kubernetes-client.proj b/kubernetes-client.proj new file mode 100644 index 000000000..9f634d328 --- /dev/null +++ b/kubernetes-client.proj @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/kubernetes-client.ruleset b/kubernetes-client.ruleset index f1221e98d..8baea16b9 100644 --- a/kubernetes-client.ruleset +++ b/kubernetes-client.ruleset @@ -51,9 +51,6 @@ - - - diff --git a/kubernetes-client.sln b/kubernetes-client.sln deleted file mode 100644 index 698be9190..000000000 --- a/kubernetes-client.sln +++ /dev/null @@ -1,496 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.31903.59 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{B70AFB57-57C9-46DC-84BE-11B7DDD34B40}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "attach", "examples\attach\attach.csproj", "{87CD4259-88DC-4748-AC61-CDDFB6E02891}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "exec", "examples\exec\exec.csproj", "{0044011C-25A6-4303-AA3F-877244B51ABB}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "labels", "examples\labels\labels.csproj", "{D5471F2E-F522-47E7-B3D2-F98A4452E214}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "logs", "examples\logs\logs.csproj", "{4BD050E8-B0E4-40B4-AC72-5130D81095C7}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "namespace", "examples\namespace\namespace.csproj", "{1AA79D75-E7C4-4C0C-928B-FB12EC3CBF68}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "simple", "examples\simple\simple.csproj", "{DDB14203-DD5B-452A-A1E0-9FD98629101F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "watch", "examples\watch\watch.csproj", "{1DDB0CCF-7CCE-4A60-BAC6-9AE1779DEDB5}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3D1864AA-1FFC-4512-BB13-46055E410F73}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KubernetesClient", "src\KubernetesClient\KubernetesClient.csproj", "{35DD7248-F9EC-4272-A32C-B0C59E5A6FA7}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{8AF4A5C2-F0CE-47D5-A4C5-FE4AB83CA509}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KubernetesClient.Tests", "tests\KubernetesClient.Tests\KubernetesClient.Tests.csproj", "{806AD0E5-833F-42FB-A870-4BCEE7F4B17F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "patch", "examples\patch\patch.csproj", "{04DE2C84-117D-4E21-8B45-B7AE627697BD}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "metrics", "examples\metrics\metrics.csproj", "{B9647AD4-F6B0-406F-8B79-6781E31600EC}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "E2E.Tests", "tests\E2E.Tests\E2E.Tests.csproj", "{5056C4A2-5E12-4C16-8DA7-8835DA58BFF2}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkipTestLogger", "tests\SkipTestLogger\SkipTestLogger.csproj", "{4D2AE427-F856-49E5-B61D-EA6B17D89051}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "customResource", "examples\customResource\customResource.csproj", "{95672061-5799-4454-ACDB-D6D330DB1EC4}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "generic", "examples\generic\generic.csproj", "{F06D4C3A-7825-43A8-832B-6BDE3D355486}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibKubernetesGenerator", "src\LibKubernetesGenerator\LibKubernetesGenerator.csproj", "{64C71596-B916-46EF-8115-B53E238F79D4}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "portforward", "examples\portforward\portforward.csproj", "{DFBB1025-BD22-459D-A04D-E2AB31E129E2}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "prometheus", "examples\prometheus\prometheus.csproj", "{682B94E4-1761-48FF-B5D0-87B45DC0C735}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "yaml", "examples\yaml\yaml.csproj", "{17AB0AD8-6C90-42DD-880C-16B5AC4A373F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KubernetesClient.Models", "src\KubernetesClient.Models\KubernetesClient.Models.csproj", "{F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KubernetesClient.Basic", "src\KubernetesClient.Basic\KubernetesClient.Basic.csproj", "{927995F5-05CC-4078-8805-8E6CC06914D8}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KubernetesClient.Classic", "src\KubernetesClient.Classic\KubernetesClient.Classic.csproj", "{80F19E8A-F097-4AA4-A68C-D417B96BBC68}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KubernetesClient.Classic.Tests", "tests\KubernetesClient.Classic.Tests\KubernetesClient.Classic.Tests.csproj", "{FD90C861-56C6-4536-B7F5-AC7779296384}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "csrApproval", "examples\csrApproval\csrApproval.csproj", "{F626860C-F141-45B3-9DDD-88AD3932ACAF}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "restart", "examples\restart\restart.csproj", "{973CCB4A-F344-4C4F-81A5-0F40F7F43C07}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KubernetesClient.Kubectl", "src\KubernetesClient.Kubectl\KubernetesClient.Kubectl.csproj", "{21201F30-5463-4FC6-93C3-FBF157F0D46C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kubectl.Tests", "tests\Kubectl.Tests\Kubectl.Tests.csproj", "{9128F6DC-6B7A-417F-937A-90461D6989A8}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "openTelemetryConsole", "examples\openTelemetryConsole\openTelemetryConsole.csproj", "{8E266190-AE6E-44A8-948D-BD974AA82428}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "webApiDependencyInjection", "examples\webApiDependencyInjection\webApiDependencyInjection.csproj", "{C0759F88-A010-4DEF-BD3B-E183D3328FFC}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "workerServiceDependencyInjection", "examples\workerServiceDependencyInjection\workerServiceDependencyInjection.csproj", "{05DC8884-AC54-4603-AC25-AE9D9F24E7AE}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "cp", "examples\cp\cp.csproj", "{CC41E248-2139-427E-8DD4-B047A8924FD2}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {87CD4259-88DC-4748-AC61-CDDFB6E02891}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {87CD4259-88DC-4748-AC61-CDDFB6E02891}.Debug|Any CPU.Build.0 = Debug|Any CPU - {87CD4259-88DC-4748-AC61-CDDFB6E02891}.Debug|x64.ActiveCfg = Debug|Any CPU - {87CD4259-88DC-4748-AC61-CDDFB6E02891}.Debug|x64.Build.0 = Debug|Any CPU - {87CD4259-88DC-4748-AC61-CDDFB6E02891}.Debug|x86.ActiveCfg = Debug|Any CPU - {87CD4259-88DC-4748-AC61-CDDFB6E02891}.Debug|x86.Build.0 = Debug|Any CPU - {87CD4259-88DC-4748-AC61-CDDFB6E02891}.Release|Any CPU.ActiveCfg = Release|Any CPU - {87CD4259-88DC-4748-AC61-CDDFB6E02891}.Release|Any CPU.Build.0 = Release|Any CPU - {87CD4259-88DC-4748-AC61-CDDFB6E02891}.Release|x64.ActiveCfg = Release|Any CPU - {87CD4259-88DC-4748-AC61-CDDFB6E02891}.Release|x64.Build.0 = Release|Any CPU - {87CD4259-88DC-4748-AC61-CDDFB6E02891}.Release|x86.ActiveCfg = Release|Any CPU - {87CD4259-88DC-4748-AC61-CDDFB6E02891}.Release|x86.Build.0 = Release|Any CPU - {0044011C-25A6-4303-AA3F-877244B51ABB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0044011C-25A6-4303-AA3F-877244B51ABB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0044011C-25A6-4303-AA3F-877244B51ABB}.Debug|x64.ActiveCfg = Debug|Any CPU - {0044011C-25A6-4303-AA3F-877244B51ABB}.Debug|x64.Build.0 = Debug|Any CPU - {0044011C-25A6-4303-AA3F-877244B51ABB}.Debug|x86.ActiveCfg = Debug|Any CPU - {0044011C-25A6-4303-AA3F-877244B51ABB}.Debug|x86.Build.0 = Debug|Any CPU - {0044011C-25A6-4303-AA3F-877244B51ABB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0044011C-25A6-4303-AA3F-877244B51ABB}.Release|Any CPU.Build.0 = Release|Any CPU - {0044011C-25A6-4303-AA3F-877244B51ABB}.Release|x64.ActiveCfg = Release|Any CPU - {0044011C-25A6-4303-AA3F-877244B51ABB}.Release|x64.Build.0 = Release|Any CPU - {0044011C-25A6-4303-AA3F-877244B51ABB}.Release|x86.ActiveCfg = Release|Any CPU - {0044011C-25A6-4303-AA3F-877244B51ABB}.Release|x86.Build.0 = Release|Any CPU - {D5471F2E-F522-47E7-B3D2-F98A4452E214}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D5471F2E-F522-47E7-B3D2-F98A4452E214}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D5471F2E-F522-47E7-B3D2-F98A4452E214}.Debug|x64.ActiveCfg = Debug|Any CPU - {D5471F2E-F522-47E7-B3D2-F98A4452E214}.Debug|x64.Build.0 = Debug|Any CPU - {D5471F2E-F522-47E7-B3D2-F98A4452E214}.Debug|x86.ActiveCfg = Debug|Any CPU - {D5471F2E-F522-47E7-B3D2-F98A4452E214}.Debug|x86.Build.0 = Debug|Any CPU - {D5471F2E-F522-47E7-B3D2-F98A4452E214}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D5471F2E-F522-47E7-B3D2-F98A4452E214}.Release|Any CPU.Build.0 = Release|Any CPU - {D5471F2E-F522-47E7-B3D2-F98A4452E214}.Release|x64.ActiveCfg = Release|Any CPU - {D5471F2E-F522-47E7-B3D2-F98A4452E214}.Release|x64.Build.0 = Release|Any CPU - {D5471F2E-F522-47E7-B3D2-F98A4452E214}.Release|x86.ActiveCfg = Release|Any CPU - {D5471F2E-F522-47E7-B3D2-F98A4452E214}.Release|x86.Build.0 = Release|Any CPU - {4BD050E8-B0E4-40B4-AC72-5130D81095C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4BD050E8-B0E4-40B4-AC72-5130D81095C7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4BD050E8-B0E4-40B4-AC72-5130D81095C7}.Debug|x64.ActiveCfg = Debug|Any CPU - {4BD050E8-B0E4-40B4-AC72-5130D81095C7}.Debug|x64.Build.0 = Debug|Any CPU - {4BD050E8-B0E4-40B4-AC72-5130D81095C7}.Debug|x86.ActiveCfg = Debug|Any CPU - {4BD050E8-B0E4-40B4-AC72-5130D81095C7}.Debug|x86.Build.0 = Debug|Any CPU - {4BD050E8-B0E4-40B4-AC72-5130D81095C7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4BD050E8-B0E4-40B4-AC72-5130D81095C7}.Release|Any CPU.Build.0 = Release|Any CPU - {4BD050E8-B0E4-40B4-AC72-5130D81095C7}.Release|x64.ActiveCfg = Release|Any CPU - {4BD050E8-B0E4-40B4-AC72-5130D81095C7}.Release|x64.Build.0 = Release|Any CPU - {4BD050E8-B0E4-40B4-AC72-5130D81095C7}.Release|x86.ActiveCfg = Release|Any CPU - {4BD050E8-B0E4-40B4-AC72-5130D81095C7}.Release|x86.Build.0 = Release|Any CPU - {1AA79D75-E7C4-4C0C-928B-FB12EC3CBF68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1AA79D75-E7C4-4C0C-928B-FB12EC3CBF68}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1AA79D75-E7C4-4C0C-928B-FB12EC3CBF68}.Debug|x64.ActiveCfg = Debug|Any CPU - {1AA79D75-E7C4-4C0C-928B-FB12EC3CBF68}.Debug|x64.Build.0 = Debug|Any CPU - {1AA79D75-E7C4-4C0C-928B-FB12EC3CBF68}.Debug|x86.ActiveCfg = Debug|Any CPU - {1AA79D75-E7C4-4C0C-928B-FB12EC3CBF68}.Debug|x86.Build.0 = Debug|Any CPU - {1AA79D75-E7C4-4C0C-928B-FB12EC3CBF68}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1AA79D75-E7C4-4C0C-928B-FB12EC3CBF68}.Release|Any CPU.Build.0 = Release|Any CPU - {1AA79D75-E7C4-4C0C-928B-FB12EC3CBF68}.Release|x64.ActiveCfg = Release|Any CPU - {1AA79D75-E7C4-4C0C-928B-FB12EC3CBF68}.Release|x64.Build.0 = Release|Any CPU - {1AA79D75-E7C4-4C0C-928B-FB12EC3CBF68}.Release|x86.ActiveCfg = Release|Any CPU - {1AA79D75-E7C4-4C0C-928B-FB12EC3CBF68}.Release|x86.Build.0 = Release|Any CPU - {DDB14203-DD5B-452A-A1E0-9FD98629101F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DDB14203-DD5B-452A-A1E0-9FD98629101F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DDB14203-DD5B-452A-A1E0-9FD98629101F}.Debug|x64.ActiveCfg = Debug|Any CPU - {DDB14203-DD5B-452A-A1E0-9FD98629101F}.Debug|x64.Build.0 = Debug|Any CPU - {DDB14203-DD5B-452A-A1E0-9FD98629101F}.Debug|x86.ActiveCfg = Debug|Any CPU - {DDB14203-DD5B-452A-A1E0-9FD98629101F}.Debug|x86.Build.0 = Debug|Any CPU - {DDB14203-DD5B-452A-A1E0-9FD98629101F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DDB14203-DD5B-452A-A1E0-9FD98629101F}.Release|Any CPU.Build.0 = Release|Any CPU - {DDB14203-DD5B-452A-A1E0-9FD98629101F}.Release|x64.ActiveCfg = Release|Any CPU - {DDB14203-DD5B-452A-A1E0-9FD98629101F}.Release|x64.Build.0 = Release|Any CPU - {DDB14203-DD5B-452A-A1E0-9FD98629101F}.Release|x86.ActiveCfg = Release|Any CPU - {DDB14203-DD5B-452A-A1E0-9FD98629101F}.Release|x86.Build.0 = Release|Any CPU - {1DDB0CCF-7CCE-4A60-BAC6-9AE1779DEDB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1DDB0CCF-7CCE-4A60-BAC6-9AE1779DEDB5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1DDB0CCF-7CCE-4A60-BAC6-9AE1779DEDB5}.Debug|x64.ActiveCfg = Debug|Any CPU - {1DDB0CCF-7CCE-4A60-BAC6-9AE1779DEDB5}.Debug|x64.Build.0 = Debug|Any CPU - {1DDB0CCF-7CCE-4A60-BAC6-9AE1779DEDB5}.Debug|x86.ActiveCfg = Debug|Any CPU - {1DDB0CCF-7CCE-4A60-BAC6-9AE1779DEDB5}.Debug|x86.Build.0 = Debug|Any CPU - {1DDB0CCF-7CCE-4A60-BAC6-9AE1779DEDB5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1DDB0CCF-7CCE-4A60-BAC6-9AE1779DEDB5}.Release|Any CPU.Build.0 = Release|Any CPU - {1DDB0CCF-7CCE-4A60-BAC6-9AE1779DEDB5}.Release|x64.ActiveCfg = Release|Any CPU - {1DDB0CCF-7CCE-4A60-BAC6-9AE1779DEDB5}.Release|x64.Build.0 = Release|Any CPU - {1DDB0CCF-7CCE-4A60-BAC6-9AE1779DEDB5}.Release|x86.ActiveCfg = Release|Any CPU - {1DDB0CCF-7CCE-4A60-BAC6-9AE1779DEDB5}.Release|x86.Build.0 = Release|Any CPU - {35DD7248-F9EC-4272-A32C-B0C59E5A6FA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {35DD7248-F9EC-4272-A32C-B0C59E5A6FA7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {35DD7248-F9EC-4272-A32C-B0C59E5A6FA7}.Debug|x64.ActiveCfg = Debug|Any CPU - {35DD7248-F9EC-4272-A32C-B0C59E5A6FA7}.Debug|x64.Build.0 = Debug|Any CPU - {35DD7248-F9EC-4272-A32C-B0C59E5A6FA7}.Debug|x86.ActiveCfg = Debug|Any CPU - {35DD7248-F9EC-4272-A32C-B0C59E5A6FA7}.Debug|x86.Build.0 = Debug|Any CPU - {35DD7248-F9EC-4272-A32C-B0C59E5A6FA7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {35DD7248-F9EC-4272-A32C-B0C59E5A6FA7}.Release|Any CPU.Build.0 = Release|Any CPU - {35DD7248-F9EC-4272-A32C-B0C59E5A6FA7}.Release|x64.ActiveCfg = Release|Any CPU - {35DD7248-F9EC-4272-A32C-B0C59E5A6FA7}.Release|x64.Build.0 = Release|Any CPU - {35DD7248-F9EC-4272-A32C-B0C59E5A6FA7}.Release|x86.ActiveCfg = Release|Any CPU - {35DD7248-F9EC-4272-A32C-B0C59E5A6FA7}.Release|x86.Build.0 = Release|Any CPU - {806AD0E5-833F-42FB-A870-4BCEE7F4B17F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {806AD0E5-833F-42FB-A870-4BCEE7F4B17F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {806AD0E5-833F-42FB-A870-4BCEE7F4B17F}.Debug|x64.ActiveCfg = Debug|Any CPU - {806AD0E5-833F-42FB-A870-4BCEE7F4B17F}.Debug|x64.Build.0 = Debug|Any CPU - {806AD0E5-833F-42FB-A870-4BCEE7F4B17F}.Debug|x86.ActiveCfg = Debug|Any CPU - {806AD0E5-833F-42FB-A870-4BCEE7F4B17F}.Debug|x86.Build.0 = Debug|Any CPU - {806AD0E5-833F-42FB-A870-4BCEE7F4B17F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {806AD0E5-833F-42FB-A870-4BCEE7F4B17F}.Release|Any CPU.Build.0 = Release|Any CPU - {806AD0E5-833F-42FB-A870-4BCEE7F4B17F}.Release|x64.ActiveCfg = Release|Any CPU - {806AD0E5-833F-42FB-A870-4BCEE7F4B17F}.Release|x64.Build.0 = Release|Any CPU - {806AD0E5-833F-42FB-A870-4BCEE7F4B17F}.Release|x86.ActiveCfg = Release|Any CPU - {806AD0E5-833F-42FB-A870-4BCEE7F4B17F}.Release|x86.Build.0 = Release|Any CPU - {04DE2C84-117D-4E21-8B45-B7AE627697BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {04DE2C84-117D-4E21-8B45-B7AE627697BD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {04DE2C84-117D-4E21-8B45-B7AE627697BD}.Debug|x64.ActiveCfg = Debug|Any CPU - {04DE2C84-117D-4E21-8B45-B7AE627697BD}.Debug|x64.Build.0 = Debug|Any CPU - {04DE2C84-117D-4E21-8B45-B7AE627697BD}.Debug|x86.ActiveCfg = Debug|Any CPU - {04DE2C84-117D-4E21-8B45-B7AE627697BD}.Debug|x86.Build.0 = Debug|Any CPU - {04DE2C84-117D-4E21-8B45-B7AE627697BD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {04DE2C84-117D-4E21-8B45-B7AE627697BD}.Release|Any CPU.Build.0 = Release|Any CPU - {04DE2C84-117D-4E21-8B45-B7AE627697BD}.Release|x64.ActiveCfg = Release|Any CPU - {04DE2C84-117D-4E21-8B45-B7AE627697BD}.Release|x64.Build.0 = Release|Any CPU - {04DE2C84-117D-4E21-8B45-B7AE627697BD}.Release|x86.ActiveCfg = Release|Any CPU - {04DE2C84-117D-4E21-8B45-B7AE627697BD}.Release|x86.Build.0 = Release|Any CPU - {B9647AD4-F6B0-406F-8B79-6781E31600EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B9647AD4-F6B0-406F-8B79-6781E31600EC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B9647AD4-F6B0-406F-8B79-6781E31600EC}.Debug|x64.ActiveCfg = Debug|Any CPU - {B9647AD4-F6B0-406F-8B79-6781E31600EC}.Debug|x64.Build.0 = Debug|Any CPU - {B9647AD4-F6B0-406F-8B79-6781E31600EC}.Debug|x86.ActiveCfg = Debug|Any CPU - {B9647AD4-F6B0-406F-8B79-6781E31600EC}.Debug|x86.Build.0 = Debug|Any CPU - {B9647AD4-F6B0-406F-8B79-6781E31600EC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B9647AD4-F6B0-406F-8B79-6781E31600EC}.Release|Any CPU.Build.0 = Release|Any CPU - {B9647AD4-F6B0-406F-8B79-6781E31600EC}.Release|x64.ActiveCfg = Release|Any CPU - {B9647AD4-F6B0-406F-8B79-6781E31600EC}.Release|x64.Build.0 = Release|Any CPU - {B9647AD4-F6B0-406F-8B79-6781E31600EC}.Release|x86.ActiveCfg = Release|Any CPU - {B9647AD4-F6B0-406F-8B79-6781E31600EC}.Release|x86.Build.0 = Release|Any CPU - {5056C4A2-5E12-4C16-8DA7-8835DA58BFF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5056C4A2-5E12-4C16-8DA7-8835DA58BFF2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5056C4A2-5E12-4C16-8DA7-8835DA58BFF2}.Debug|x64.ActiveCfg = Debug|Any CPU - {5056C4A2-5E12-4C16-8DA7-8835DA58BFF2}.Debug|x64.Build.0 = Debug|Any CPU - {5056C4A2-5E12-4C16-8DA7-8835DA58BFF2}.Debug|x86.ActiveCfg = Debug|Any CPU - {5056C4A2-5E12-4C16-8DA7-8835DA58BFF2}.Debug|x86.Build.0 = Debug|Any CPU - {5056C4A2-5E12-4C16-8DA7-8835DA58BFF2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5056C4A2-5E12-4C16-8DA7-8835DA58BFF2}.Release|Any CPU.Build.0 = Release|Any CPU - {5056C4A2-5E12-4C16-8DA7-8835DA58BFF2}.Release|x64.ActiveCfg = Release|Any CPU - {5056C4A2-5E12-4C16-8DA7-8835DA58BFF2}.Release|x64.Build.0 = Release|Any CPU - {5056C4A2-5E12-4C16-8DA7-8835DA58BFF2}.Release|x86.ActiveCfg = Release|Any CPU - {5056C4A2-5E12-4C16-8DA7-8835DA58BFF2}.Release|x86.Build.0 = Release|Any CPU - {4D2AE427-F856-49E5-B61D-EA6B17D89051}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4D2AE427-F856-49E5-B61D-EA6B17D89051}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4D2AE427-F856-49E5-B61D-EA6B17D89051}.Debug|x64.ActiveCfg = Debug|Any CPU - {4D2AE427-F856-49E5-B61D-EA6B17D89051}.Debug|x64.Build.0 = Debug|Any CPU - {4D2AE427-F856-49E5-B61D-EA6B17D89051}.Debug|x86.ActiveCfg = Debug|Any CPU - {4D2AE427-F856-49E5-B61D-EA6B17D89051}.Debug|x86.Build.0 = Debug|Any CPU - {4D2AE427-F856-49E5-B61D-EA6B17D89051}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4D2AE427-F856-49E5-B61D-EA6B17D89051}.Release|Any CPU.Build.0 = Release|Any CPU - {4D2AE427-F856-49E5-B61D-EA6B17D89051}.Release|x64.ActiveCfg = Release|Any CPU - {4D2AE427-F856-49E5-B61D-EA6B17D89051}.Release|x64.Build.0 = Release|Any CPU - {4D2AE427-F856-49E5-B61D-EA6B17D89051}.Release|x86.ActiveCfg = Release|Any CPU - {4D2AE427-F856-49E5-B61D-EA6B17D89051}.Release|x86.Build.0 = Release|Any CPU - {95672061-5799-4454-ACDB-D6D330DB1EC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {95672061-5799-4454-ACDB-D6D330DB1EC4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {95672061-5799-4454-ACDB-D6D330DB1EC4}.Debug|x64.ActiveCfg = Debug|Any CPU - {95672061-5799-4454-ACDB-D6D330DB1EC4}.Debug|x64.Build.0 = Debug|Any CPU - {95672061-5799-4454-ACDB-D6D330DB1EC4}.Debug|x86.ActiveCfg = Debug|Any CPU - {95672061-5799-4454-ACDB-D6D330DB1EC4}.Debug|x86.Build.0 = Debug|Any CPU - {95672061-5799-4454-ACDB-D6D330DB1EC4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {95672061-5799-4454-ACDB-D6D330DB1EC4}.Release|Any CPU.Build.0 = Release|Any CPU - {95672061-5799-4454-ACDB-D6D330DB1EC4}.Release|x64.ActiveCfg = Release|Any CPU - {95672061-5799-4454-ACDB-D6D330DB1EC4}.Release|x64.Build.0 = Release|Any CPU - {95672061-5799-4454-ACDB-D6D330DB1EC4}.Release|x86.ActiveCfg = Release|Any CPU - {95672061-5799-4454-ACDB-D6D330DB1EC4}.Release|x86.Build.0 = Release|Any CPU - {F06D4C3A-7825-43A8-832B-6BDE3D355486}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F06D4C3A-7825-43A8-832B-6BDE3D355486}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F06D4C3A-7825-43A8-832B-6BDE3D355486}.Debug|x64.ActiveCfg = Debug|Any CPU - {F06D4C3A-7825-43A8-832B-6BDE3D355486}.Debug|x64.Build.0 = Debug|Any CPU - {F06D4C3A-7825-43A8-832B-6BDE3D355486}.Debug|x86.ActiveCfg = Debug|Any CPU - {F06D4C3A-7825-43A8-832B-6BDE3D355486}.Debug|x86.Build.0 = Debug|Any CPU - {F06D4C3A-7825-43A8-832B-6BDE3D355486}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F06D4C3A-7825-43A8-832B-6BDE3D355486}.Release|Any CPU.Build.0 = Release|Any CPU - {F06D4C3A-7825-43A8-832B-6BDE3D355486}.Release|x64.ActiveCfg = Release|Any CPU - {F06D4C3A-7825-43A8-832B-6BDE3D355486}.Release|x64.Build.0 = Release|Any CPU - {F06D4C3A-7825-43A8-832B-6BDE3D355486}.Release|x86.ActiveCfg = Release|Any CPU - {F06D4C3A-7825-43A8-832B-6BDE3D355486}.Release|x86.Build.0 = Release|Any CPU - {64C71596-B916-46EF-8115-B53E238F79D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {64C71596-B916-46EF-8115-B53E238F79D4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {64C71596-B916-46EF-8115-B53E238F79D4}.Debug|x64.ActiveCfg = Debug|Any CPU - {64C71596-B916-46EF-8115-B53E238F79D4}.Debug|x64.Build.0 = Debug|Any CPU - {64C71596-B916-46EF-8115-B53E238F79D4}.Debug|x86.ActiveCfg = Debug|Any CPU - {64C71596-B916-46EF-8115-B53E238F79D4}.Debug|x86.Build.0 = Debug|Any CPU - {64C71596-B916-46EF-8115-B53E238F79D4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {64C71596-B916-46EF-8115-B53E238F79D4}.Release|Any CPU.Build.0 = Release|Any CPU - {64C71596-B916-46EF-8115-B53E238F79D4}.Release|x64.ActiveCfg = Release|Any CPU - {64C71596-B916-46EF-8115-B53E238F79D4}.Release|x64.Build.0 = Release|Any CPU - {64C71596-B916-46EF-8115-B53E238F79D4}.Release|x86.ActiveCfg = Release|Any CPU - {64C71596-B916-46EF-8115-B53E238F79D4}.Release|x86.Build.0 = Release|Any CPU - {DFBB1025-BD22-459D-A04D-E2AB31E129E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DFBB1025-BD22-459D-A04D-E2AB31E129E2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DFBB1025-BD22-459D-A04D-E2AB31E129E2}.Debug|x64.ActiveCfg = Debug|Any CPU - {DFBB1025-BD22-459D-A04D-E2AB31E129E2}.Debug|x64.Build.0 = Debug|Any CPU - {DFBB1025-BD22-459D-A04D-E2AB31E129E2}.Debug|x86.ActiveCfg = Debug|Any CPU - {DFBB1025-BD22-459D-A04D-E2AB31E129E2}.Debug|x86.Build.0 = Debug|Any CPU - {DFBB1025-BD22-459D-A04D-E2AB31E129E2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DFBB1025-BD22-459D-A04D-E2AB31E129E2}.Release|Any CPU.Build.0 = Release|Any CPU - {DFBB1025-BD22-459D-A04D-E2AB31E129E2}.Release|x64.ActiveCfg = Release|Any CPU - {DFBB1025-BD22-459D-A04D-E2AB31E129E2}.Release|x64.Build.0 = Release|Any CPU - {DFBB1025-BD22-459D-A04D-E2AB31E129E2}.Release|x86.ActiveCfg = Release|Any CPU - {DFBB1025-BD22-459D-A04D-E2AB31E129E2}.Release|x86.Build.0 = Release|Any CPU - {682B94E4-1761-48FF-B5D0-87B45DC0C735}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {682B94E4-1761-48FF-B5D0-87B45DC0C735}.Debug|Any CPU.Build.0 = Debug|Any CPU - {682B94E4-1761-48FF-B5D0-87B45DC0C735}.Debug|x64.ActiveCfg = Debug|Any CPU - {682B94E4-1761-48FF-B5D0-87B45DC0C735}.Debug|x64.Build.0 = Debug|Any CPU - {682B94E4-1761-48FF-B5D0-87B45DC0C735}.Debug|x86.ActiveCfg = Debug|Any CPU - {682B94E4-1761-48FF-B5D0-87B45DC0C735}.Debug|x86.Build.0 = Debug|Any CPU - {682B94E4-1761-48FF-B5D0-87B45DC0C735}.Release|Any CPU.ActiveCfg = Release|Any CPU - {682B94E4-1761-48FF-B5D0-87B45DC0C735}.Release|Any CPU.Build.0 = Release|Any CPU - {682B94E4-1761-48FF-B5D0-87B45DC0C735}.Release|x64.ActiveCfg = Release|Any CPU - {682B94E4-1761-48FF-B5D0-87B45DC0C735}.Release|x64.Build.0 = Release|Any CPU - {682B94E4-1761-48FF-B5D0-87B45DC0C735}.Release|x86.ActiveCfg = Release|Any CPU - {682B94E4-1761-48FF-B5D0-87B45DC0C735}.Release|x86.Build.0 = Release|Any CPU - {17AB0AD8-6C90-42DD-880C-16B5AC4A373F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {17AB0AD8-6C90-42DD-880C-16B5AC4A373F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {17AB0AD8-6C90-42DD-880C-16B5AC4A373F}.Debug|x64.ActiveCfg = Debug|Any CPU - {17AB0AD8-6C90-42DD-880C-16B5AC4A373F}.Debug|x64.Build.0 = Debug|Any CPU - {17AB0AD8-6C90-42DD-880C-16B5AC4A373F}.Debug|x86.ActiveCfg = Debug|Any CPU - {17AB0AD8-6C90-42DD-880C-16B5AC4A373F}.Debug|x86.Build.0 = Debug|Any CPU - {17AB0AD8-6C90-42DD-880C-16B5AC4A373F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {17AB0AD8-6C90-42DD-880C-16B5AC4A373F}.Release|Any CPU.Build.0 = Release|Any CPU - {17AB0AD8-6C90-42DD-880C-16B5AC4A373F}.Release|x64.ActiveCfg = Release|Any CPU - {17AB0AD8-6C90-42DD-880C-16B5AC4A373F}.Release|x64.Build.0 = Release|Any CPU - {17AB0AD8-6C90-42DD-880C-16B5AC4A373F}.Release|x86.ActiveCfg = Release|Any CPU - {17AB0AD8-6C90-42DD-880C-16B5AC4A373F}.Release|x86.Build.0 = Release|Any CPU - {F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Debug|x64.ActiveCfg = Debug|Any CPU - {F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Debug|x64.Build.0 = Debug|Any CPU - {F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Debug|x86.ActiveCfg = Debug|Any CPU - {F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Debug|x86.Build.0 = Debug|Any CPU - {F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Release|Any CPU.Build.0 = Release|Any CPU - {F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Release|x64.ActiveCfg = Release|Any CPU - {F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Release|x64.Build.0 = Release|Any CPU - {F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Release|x86.ActiveCfg = Release|Any CPU - {F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Release|x86.Build.0 = Release|Any CPU - {927995F5-05CC-4078-8805-8E6CC06914D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {927995F5-05CC-4078-8805-8E6CC06914D8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {927995F5-05CC-4078-8805-8E6CC06914D8}.Debug|x64.ActiveCfg = Debug|Any CPU - {927995F5-05CC-4078-8805-8E6CC06914D8}.Debug|x64.Build.0 = Debug|Any CPU - {927995F5-05CC-4078-8805-8E6CC06914D8}.Debug|x86.ActiveCfg = Debug|Any CPU - {927995F5-05CC-4078-8805-8E6CC06914D8}.Debug|x86.Build.0 = Debug|Any CPU - {927995F5-05CC-4078-8805-8E6CC06914D8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {927995F5-05CC-4078-8805-8E6CC06914D8}.Release|Any CPU.Build.0 = Release|Any CPU - {927995F5-05CC-4078-8805-8E6CC06914D8}.Release|x64.ActiveCfg = Release|Any CPU - {927995F5-05CC-4078-8805-8E6CC06914D8}.Release|x64.Build.0 = Release|Any CPU - {927995F5-05CC-4078-8805-8E6CC06914D8}.Release|x86.ActiveCfg = Release|Any CPU - {927995F5-05CC-4078-8805-8E6CC06914D8}.Release|x86.Build.0 = Release|Any CPU - {80F19E8A-F097-4AA4-A68C-D417B96BBC68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {80F19E8A-F097-4AA4-A68C-D417B96BBC68}.Debug|Any CPU.Build.0 = Debug|Any CPU - {80F19E8A-F097-4AA4-A68C-D417B96BBC68}.Debug|x64.ActiveCfg = Debug|Any CPU - {80F19E8A-F097-4AA4-A68C-D417B96BBC68}.Debug|x64.Build.0 = Debug|Any CPU - {80F19E8A-F097-4AA4-A68C-D417B96BBC68}.Debug|x86.ActiveCfg = Debug|Any CPU - {80F19E8A-F097-4AA4-A68C-D417B96BBC68}.Debug|x86.Build.0 = Debug|Any CPU - {80F19E8A-F097-4AA4-A68C-D417B96BBC68}.Release|Any CPU.ActiveCfg = Release|Any CPU - {80F19E8A-F097-4AA4-A68C-D417B96BBC68}.Release|Any CPU.Build.0 = Release|Any CPU - {80F19E8A-F097-4AA4-A68C-D417B96BBC68}.Release|x64.ActiveCfg = Release|Any CPU - {80F19E8A-F097-4AA4-A68C-D417B96BBC68}.Release|x64.Build.0 = Release|Any CPU - {80F19E8A-F097-4AA4-A68C-D417B96BBC68}.Release|x86.ActiveCfg = Release|Any CPU - {80F19E8A-F097-4AA4-A68C-D417B96BBC68}.Release|x86.Build.0 = Release|Any CPU - {FD90C861-56C6-4536-B7F5-AC7779296384}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FD90C861-56C6-4536-B7F5-AC7779296384}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FD90C861-56C6-4536-B7F5-AC7779296384}.Debug|x64.ActiveCfg = Debug|Any CPU - {FD90C861-56C6-4536-B7F5-AC7779296384}.Debug|x64.Build.0 = Debug|Any CPU - {FD90C861-56C6-4536-B7F5-AC7779296384}.Debug|x86.ActiveCfg = Debug|Any CPU - {FD90C861-56C6-4536-B7F5-AC7779296384}.Debug|x86.Build.0 = Debug|Any CPU - {FD90C861-56C6-4536-B7F5-AC7779296384}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FD90C861-56C6-4536-B7F5-AC7779296384}.Release|Any CPU.Build.0 = Release|Any CPU - {FD90C861-56C6-4536-B7F5-AC7779296384}.Release|x64.ActiveCfg = Release|Any CPU - {FD90C861-56C6-4536-B7F5-AC7779296384}.Release|x64.Build.0 = Release|Any CPU - {FD90C861-56C6-4536-B7F5-AC7779296384}.Release|x86.ActiveCfg = Release|Any CPU - {FD90C861-56C6-4536-B7F5-AC7779296384}.Release|x86.Build.0 = Release|Any CPU - {F626860C-F141-45B3-9DDD-88AD3932ACAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F626860C-F141-45B3-9DDD-88AD3932ACAF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F626860C-F141-45B3-9DDD-88AD3932ACAF}.Debug|x64.ActiveCfg = Debug|Any CPU - {F626860C-F141-45B3-9DDD-88AD3932ACAF}.Debug|x64.Build.0 = Debug|Any CPU - {F626860C-F141-45B3-9DDD-88AD3932ACAF}.Debug|x86.ActiveCfg = Debug|Any CPU - {F626860C-F141-45B3-9DDD-88AD3932ACAF}.Debug|x86.Build.0 = Debug|Any CPU - {F626860C-F141-45B3-9DDD-88AD3932ACAF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F626860C-F141-45B3-9DDD-88AD3932ACAF}.Release|Any CPU.Build.0 = Release|Any CPU - {F626860C-F141-45B3-9DDD-88AD3932ACAF}.Release|x64.ActiveCfg = Release|Any CPU - {F626860C-F141-45B3-9DDD-88AD3932ACAF}.Release|x64.Build.0 = Release|Any CPU - {F626860C-F141-45B3-9DDD-88AD3932ACAF}.Release|x86.ActiveCfg = Release|Any CPU - {F626860C-F141-45B3-9DDD-88AD3932ACAF}.Release|x86.Build.0 = Release|Any CPU - {973CCB4A-F344-4C4F-81A5-0F40F7F43C07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {973CCB4A-F344-4C4F-81A5-0F40F7F43C07}.Debug|Any CPU.Build.0 = Debug|Any CPU - {973CCB4A-F344-4C4F-81A5-0F40F7F43C07}.Debug|x64.ActiveCfg = Debug|Any CPU - {973CCB4A-F344-4C4F-81A5-0F40F7F43C07}.Debug|x64.Build.0 = Debug|Any CPU - {973CCB4A-F344-4C4F-81A5-0F40F7F43C07}.Debug|x86.ActiveCfg = Debug|Any CPU - {973CCB4A-F344-4C4F-81A5-0F40F7F43C07}.Debug|x86.Build.0 = Debug|Any CPU - {973CCB4A-F344-4C4F-81A5-0F40F7F43C07}.Release|Any CPU.ActiveCfg = Release|Any CPU - {973CCB4A-F344-4C4F-81A5-0F40F7F43C07}.Release|Any CPU.Build.0 = Release|Any CPU - {973CCB4A-F344-4C4F-81A5-0F40F7F43C07}.Release|x64.ActiveCfg = Release|Any CPU - {973CCB4A-F344-4C4F-81A5-0F40F7F43C07}.Release|x64.Build.0 = Release|Any CPU - {973CCB4A-F344-4C4F-81A5-0F40F7F43C07}.Release|x86.ActiveCfg = Release|Any CPU - {973CCB4A-F344-4C4F-81A5-0F40F7F43C07}.Release|x86.Build.0 = Release|Any CPU - {21201F30-5463-4FC6-93C3-FBF157F0D46C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {21201F30-5463-4FC6-93C3-FBF157F0D46C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {21201F30-5463-4FC6-93C3-FBF157F0D46C}.Debug|x64.ActiveCfg = Debug|Any CPU - {21201F30-5463-4FC6-93C3-FBF157F0D46C}.Debug|x64.Build.0 = Debug|Any CPU - {21201F30-5463-4FC6-93C3-FBF157F0D46C}.Debug|x86.ActiveCfg = Debug|Any CPU - {21201F30-5463-4FC6-93C3-FBF157F0D46C}.Debug|x86.Build.0 = Debug|Any CPU - {21201F30-5463-4FC6-93C3-FBF157F0D46C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {21201F30-5463-4FC6-93C3-FBF157F0D46C}.Release|Any CPU.Build.0 = Release|Any CPU - {21201F30-5463-4FC6-93C3-FBF157F0D46C}.Release|x64.ActiveCfg = Release|Any CPU - {21201F30-5463-4FC6-93C3-FBF157F0D46C}.Release|x64.Build.0 = Release|Any CPU - {21201F30-5463-4FC6-93C3-FBF157F0D46C}.Release|x86.ActiveCfg = Release|Any CPU - {21201F30-5463-4FC6-93C3-FBF157F0D46C}.Release|x86.Build.0 = Release|Any CPU - {9128F6DC-6B7A-417F-937A-90461D6989A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9128F6DC-6B7A-417F-937A-90461D6989A8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9128F6DC-6B7A-417F-937A-90461D6989A8}.Debug|x64.ActiveCfg = Debug|Any CPU - {9128F6DC-6B7A-417F-937A-90461D6989A8}.Debug|x64.Build.0 = Debug|Any CPU - {9128F6DC-6B7A-417F-937A-90461D6989A8}.Debug|x86.ActiveCfg = Debug|Any CPU - {9128F6DC-6B7A-417F-937A-90461D6989A8}.Debug|x86.Build.0 = Debug|Any CPU - {9128F6DC-6B7A-417F-937A-90461D6989A8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9128F6DC-6B7A-417F-937A-90461D6989A8}.Release|Any CPU.Build.0 = Release|Any CPU - {9128F6DC-6B7A-417F-937A-90461D6989A8}.Release|x64.ActiveCfg = Release|Any CPU - {9128F6DC-6B7A-417F-937A-90461D6989A8}.Release|x64.Build.0 = Release|Any CPU - {9128F6DC-6B7A-417F-937A-90461D6989A8}.Release|x86.ActiveCfg = Release|Any CPU - {9128F6DC-6B7A-417F-937A-90461D6989A8}.Release|x86.Build.0 = Release|Any CPU - {8E266190-AE6E-44A8-948D-BD974AA82428}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8E266190-AE6E-44A8-948D-BD974AA82428}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8E266190-AE6E-44A8-948D-BD974AA82428}.Debug|x64.ActiveCfg = Debug|Any CPU - {8E266190-AE6E-44A8-948D-BD974AA82428}.Debug|x64.Build.0 = Debug|Any CPU - {8E266190-AE6E-44A8-948D-BD974AA82428}.Debug|x86.ActiveCfg = Debug|Any CPU - {8E266190-AE6E-44A8-948D-BD974AA82428}.Debug|x86.Build.0 = Debug|Any CPU - {8E266190-AE6E-44A8-948D-BD974AA82428}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8E266190-AE6E-44A8-948D-BD974AA82428}.Release|Any CPU.Build.0 = Release|Any CPU - {8E266190-AE6E-44A8-948D-BD974AA82428}.Release|x64.ActiveCfg = Release|Any CPU - {8E266190-AE6E-44A8-948D-BD974AA82428}.Release|x64.Build.0 = Release|Any CPU - {8E266190-AE6E-44A8-948D-BD974AA82428}.Release|x86.ActiveCfg = Release|Any CPU - {8E266190-AE6E-44A8-948D-BD974AA82428}.Release|x86.Build.0 = Release|Any CPU - {C0759F88-A010-4DEF-BD3B-E183D3328FFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C0759F88-A010-4DEF-BD3B-E183D3328FFC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C0759F88-A010-4DEF-BD3B-E183D3328FFC}.Debug|x64.ActiveCfg = Debug|Any CPU - {C0759F88-A010-4DEF-BD3B-E183D3328FFC}.Debug|x64.Build.0 = Debug|Any CPU - {C0759F88-A010-4DEF-BD3B-E183D3328FFC}.Debug|x86.ActiveCfg = Debug|Any CPU - {C0759F88-A010-4DEF-BD3B-E183D3328FFC}.Debug|x86.Build.0 = Debug|Any CPU - {C0759F88-A010-4DEF-BD3B-E183D3328FFC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C0759F88-A010-4DEF-BD3B-E183D3328FFC}.Release|Any CPU.Build.0 = Release|Any CPU - {C0759F88-A010-4DEF-BD3B-E183D3328FFC}.Release|x64.ActiveCfg = Release|Any CPU - {C0759F88-A010-4DEF-BD3B-E183D3328FFC}.Release|x64.Build.0 = Release|Any CPU - {C0759F88-A010-4DEF-BD3B-E183D3328FFC}.Release|x86.ActiveCfg = Release|Any CPU - {C0759F88-A010-4DEF-BD3B-E183D3328FFC}.Release|x86.Build.0 = Release|Any CPU - {05DC8884-AC54-4603-AC25-AE9D9F24E7AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {05DC8884-AC54-4603-AC25-AE9D9F24E7AE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {05DC8884-AC54-4603-AC25-AE9D9F24E7AE}.Debug|x64.ActiveCfg = Debug|Any CPU - {05DC8884-AC54-4603-AC25-AE9D9F24E7AE}.Debug|x64.Build.0 = Debug|Any CPU - {05DC8884-AC54-4603-AC25-AE9D9F24E7AE}.Debug|x86.ActiveCfg = Debug|Any CPU - {05DC8884-AC54-4603-AC25-AE9D9F24E7AE}.Debug|x86.Build.0 = Debug|Any CPU - {05DC8884-AC54-4603-AC25-AE9D9F24E7AE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {05DC8884-AC54-4603-AC25-AE9D9F24E7AE}.Release|Any CPU.Build.0 = Release|Any CPU - {05DC8884-AC54-4603-AC25-AE9D9F24E7AE}.Release|x64.ActiveCfg = Release|Any CPU - {05DC8884-AC54-4603-AC25-AE9D9F24E7AE}.Release|x64.Build.0 = Release|Any CPU - {05DC8884-AC54-4603-AC25-AE9D9F24E7AE}.Release|x86.ActiveCfg = Release|Any CPU - {05DC8884-AC54-4603-AC25-AE9D9F24E7AE}.Release|x86.Build.0 = Release|Any CPU - {CC41E248-2139-427E-8DD4-B047A8924FD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CC41E248-2139-427E-8DD4-B047A8924FD2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CC41E248-2139-427E-8DD4-B047A8924FD2}.Debug|x64.ActiveCfg = Debug|Any CPU - {CC41E248-2139-427E-8DD4-B047A8924FD2}.Debug|x64.Build.0 = Debug|Any CPU - {CC41E248-2139-427E-8DD4-B047A8924FD2}.Debug|x86.ActiveCfg = Debug|Any CPU - {CC41E248-2139-427E-8DD4-B047A8924FD2}.Debug|x86.Build.0 = Debug|Any CPU - {CC41E248-2139-427E-8DD4-B047A8924FD2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CC41E248-2139-427E-8DD4-B047A8924FD2}.Release|Any CPU.Build.0 = Release|Any CPU - {CC41E248-2139-427E-8DD4-B047A8924FD2}.Release|x64.ActiveCfg = Release|Any CPU - {CC41E248-2139-427E-8DD4-B047A8924FD2}.Release|x64.Build.0 = Release|Any CPU - {CC41E248-2139-427E-8DD4-B047A8924FD2}.Release|x86.ActiveCfg = Release|Any CPU - {CC41E248-2139-427E-8DD4-B047A8924FD2}.Release|x86.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {87CD4259-88DC-4748-AC61-CDDFB6E02891} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - {0044011C-25A6-4303-AA3F-877244B51ABB} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - {D5471F2E-F522-47E7-B3D2-F98A4452E214} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - {4BD050E8-B0E4-40B4-AC72-5130D81095C7} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - {1AA79D75-E7C4-4C0C-928B-FB12EC3CBF68} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - {DDB14203-DD5B-452A-A1E0-9FD98629101F} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - {1DDB0CCF-7CCE-4A60-BAC6-9AE1779DEDB5} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - {35DD7248-F9EC-4272-A32C-B0C59E5A6FA7} = {3D1864AA-1FFC-4512-BB13-46055E410F73} - {806AD0E5-833F-42FB-A870-4BCEE7F4B17F} = {8AF4A5C2-F0CE-47D5-A4C5-FE4AB83CA509} - {04DE2C84-117D-4E21-8B45-B7AE627697BD} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - {B9647AD4-F6B0-406F-8B79-6781E31600EC} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - {5056C4A2-5E12-4C16-8DA7-8835DA58BFF2} = {8AF4A5C2-F0CE-47D5-A4C5-FE4AB83CA509} - {4D2AE427-F856-49E5-B61D-EA6B17D89051} = {8AF4A5C2-F0CE-47D5-A4C5-FE4AB83CA509} - {95672061-5799-4454-ACDB-D6D330DB1EC4} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - {F06D4C3A-7825-43A8-832B-6BDE3D355486} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - {64C71596-B916-46EF-8115-B53E238F79D4} = {3D1864AA-1FFC-4512-BB13-46055E410F73} - {DFBB1025-BD22-459D-A04D-E2AB31E129E2} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - {682B94E4-1761-48FF-B5D0-87B45DC0C735} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - {17AB0AD8-6C90-42DD-880C-16B5AC4A373F} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - {F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8} = {3D1864AA-1FFC-4512-BB13-46055E410F73} - {927995F5-05CC-4078-8805-8E6CC06914D8} = {3D1864AA-1FFC-4512-BB13-46055E410F73} - {80F19E8A-F097-4AA4-A68C-D417B96BBC68} = {3D1864AA-1FFC-4512-BB13-46055E410F73} - {FD90C861-56C6-4536-B7F5-AC7779296384} = {8AF4A5C2-F0CE-47D5-A4C5-FE4AB83CA509} - {F626860C-F141-45B3-9DDD-88AD3932ACAF} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - {973CCB4A-F344-4C4F-81A5-0F40F7F43C07} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - {21201F30-5463-4FC6-93C3-FBF157F0D46C} = {3D1864AA-1FFC-4512-BB13-46055E410F73} - {9128F6DC-6B7A-417F-937A-90461D6989A8} = {8AF4A5C2-F0CE-47D5-A4C5-FE4AB83CA509} - {8E266190-AE6E-44A8-948D-BD974AA82428} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - {C0759F88-A010-4DEF-BD3B-E183D3328FFC} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - {05DC8884-AC54-4603-AC25-AE9D9F24E7AE} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - {CC41E248-2139-427E-8DD4-B047A8924FD2} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {049A763A-C891-4E8D-80CF-89DD3E22ADC7} - EndGlobalSection -EndGlobal diff --git a/src/KubernetesClient.Basic/Global.cs b/src/KubernetesClient.Aot/Global.cs similarity index 75% rename from src/KubernetesClient.Basic/Global.cs rename to src/KubernetesClient.Aot/Global.cs index d91efcf78..2b5a4ae8e 100644 --- a/src/KubernetesClient.Basic/Global.cs +++ b/src/KubernetesClient.Aot/Global.cs @@ -1,8 +1,10 @@ -global using System; -global using System.Collections.Generic; -global using System.Linq; global using k8s.Autorest; global using k8s.Models; +global using System; +global using System.Collections.Generic; global using System.IO; +global using System.Linq; +global using System.Text.Json; +global using System.Text.Json.Serialization; global using System.Threading; global using System.Threading.Tasks; diff --git a/src/KubernetesClient.Aot/KubeConfigModels/AuthProvider.cs b/src/KubernetesClient.Aot/KubeConfigModels/AuthProvider.cs new file mode 100644 index 000000000..5bec9095e --- /dev/null +++ b/src/KubernetesClient.Aot/KubeConfigModels/AuthProvider.cs @@ -0,0 +1,23 @@ +using YamlDotNet.Serialization; + +namespace k8s.KubeConfigModels +{ + /// + /// Contains information that describes identity information. This is use to tell the kubernetes cluster who you are. + /// + [YamlSerializable] + public class AuthProvider + { + /// + /// Gets or sets the nickname for this auth provider. + /// + [YamlMember(Alias = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the configuration for this auth provider + /// + [YamlMember(Alias = "config")] + public Dictionary Config { get; set; } + } +} diff --git a/src/KubernetesClient.Aot/KubeConfigModels/Cluster.cs b/src/KubernetesClient.Aot/KubeConfigModels/Cluster.cs new file mode 100644 index 000000000..80faf96a5 --- /dev/null +++ b/src/KubernetesClient.Aot/KubeConfigModels/Cluster.cs @@ -0,0 +1,23 @@ +using YamlDotNet.Serialization; + +namespace k8s.KubeConfigModels +{ + /// + /// Relates nicknames to cluster information. + /// + [YamlSerializable] + public class Cluster + { + /// + /// Gets or sets the cluster information. + /// + [YamlMember(Alias = "cluster")] + public ClusterEndpoint ClusterEndpoint { get; set; } + + /// + /// Gets or sets the nickname for this Cluster. + /// + [YamlMember(Alias = "name")] + public string Name { get; set; } + } +} diff --git a/src/KubernetesClient.Aot/KubeConfigModels/ClusterEndpoint.cs b/src/KubernetesClient.Aot/KubeConfigModels/ClusterEndpoint.cs new file mode 100644 index 000000000..c40827651 --- /dev/null +++ b/src/KubernetesClient.Aot/KubeConfigModels/ClusterEndpoint.cs @@ -0,0 +1,42 @@ +using YamlDotNet.Serialization; + +namespace k8s.KubeConfigModels +{ + /// + /// Contains information about how to communicate with a kubernetes cluster + /// + [YamlSerializable] + public class ClusterEndpoint + { + /// + /// Gets or sets the path to a cert file for the certificate authority. + /// + [YamlMember(Alias = "certificate-authority", ApplyNamingConventions = false)] + public string CertificateAuthority { get; set; } + + /// + /// Gets or sets =PEM-encoded certificate authority certificates. Overrides . + /// + [YamlMember(Alias = "certificate-authority-data", ApplyNamingConventions = false)] + public string CertificateAuthorityData { get; set; } + + /// + /// Gets or sets the address of the kubernetes cluster (https://hostname:port). + /// + [YamlMember(Alias = "server")] + public string Server { get; set; } + + /// + /// Gets or sets a value to override the TLS server name. + /// + [YamlMember(Alias = "tls-server-name", ApplyNamingConventions = false)] + public string TlsServerName { get; set; } + + /// + /// Gets or sets a value indicating whether to skip the validity check for the server's certificate. + /// This will make your HTTPS connections insecure. + /// + [YamlMember(Alias = "insecure-skip-tls-verify", ApplyNamingConventions = false)] + public bool SkipTlsVerify { get; set; } + } +} diff --git a/src/KubernetesClient.Aot/KubeConfigModels/Context.cs b/src/KubernetesClient.Aot/KubeConfigModels/Context.cs new file mode 100644 index 000000000..65241315f --- /dev/null +++ b/src/KubernetesClient.Aot/KubeConfigModels/Context.cs @@ -0,0 +1,23 @@ +using YamlDotNet.Serialization; + +namespace k8s.KubeConfigModels +{ + /// + /// Relates nicknames to context information. + /// + [YamlSerializable] + public class Context + { + /// + /// Gets or sets the context information. + /// + [YamlMember(Alias = "context")] + public ContextDetails ContextDetails { get; set; } + + /// + /// Gets or sets the nickname for this context. + /// + [YamlMember(Alias = "name")] + public string Name { get; set; } + } +} diff --git a/src/KubernetesClient.Aot/KubeConfigModels/ContextDetails.cs b/src/KubernetesClient.Aot/KubeConfigModels/ContextDetails.cs new file mode 100644 index 000000000..ca2bf1e07 --- /dev/null +++ b/src/KubernetesClient.Aot/KubeConfigModels/ContextDetails.cs @@ -0,0 +1,30 @@ +using YamlDotNet.Serialization; + +namespace k8s.KubeConfigModels +{ + /// + /// Represents a tuple of references to a cluster (how do I communicate with a kubernetes cluster), + /// a user (how do I identify myself), and a namespace (what subset of resources do I want to work with) + /// + [YamlSerializable] + public class ContextDetails + { + /// + /// Gets or sets the name of the cluster for this context. + /// + [YamlMember(Alias = "cluster")] + public string Cluster { get; set; } + + /// + /// Gets or sets the name of the user for this context. + /// + [YamlMember(Alias = "user")] + public string User { get; set; } + + /// + /// /Gets or sets the default namespace to use on unspecified requests. + /// + [YamlMember(Alias = "namespace")] + public string Namespace { get; set; } + } +} diff --git a/src/KubernetesClient.Aot/KubeConfigModels/ExecCredentialResponse.cs b/src/KubernetesClient.Aot/KubeConfigModels/ExecCredentialResponse.cs new file mode 100644 index 000000000..d593ff4f6 --- /dev/null +++ b/src/KubernetesClient.Aot/KubeConfigModels/ExecCredentialResponse.cs @@ -0,0 +1,35 @@ +using YamlDotNet.Serialization; + +namespace k8s.KubeConfigModels +{ + [YamlSerializable] + public class ExecCredentialResponse + { + public class ExecStatus + { +#nullable enable + [JsonPropertyName("expirationTimestamp")] + public DateTime? ExpirationTimestamp { get; set; } + [JsonPropertyName("token")] + public string? Token { get; set; } + [JsonPropertyName("clientCertificateData")] + public string? ClientCertificateData { get; set; } + [JsonPropertyName("clientKeyData")] + public string? ClientKeyData { get; set; } +#nullable disable + + public bool IsValid() + { + return !string.IsNullOrEmpty(Token) || + (!string.IsNullOrEmpty(ClientCertificateData) && !string.IsNullOrEmpty(ClientKeyData)); + } + } + + [JsonPropertyName("apiVersion")] + public string ApiVersion { get; set; } + [JsonPropertyName("kind")] + public string Kind { get; set; } + [JsonPropertyName("status")] + public ExecStatus Status { get; set; } + } +} diff --git a/src/KubernetesClient.Aot/KubeConfigModels/ExecCredentialResponseContext.cs b/src/KubernetesClient.Aot/KubeConfigModels/ExecCredentialResponseContext.cs new file mode 100644 index 000000000..c7ffd8294 --- /dev/null +++ b/src/KubernetesClient.Aot/KubeConfigModels/ExecCredentialResponseContext.cs @@ -0,0 +1,7 @@ +namespace k8s.KubeConfigModels +{ + [JsonSerializable(typeof(ExecCredentialResponse))] + internal partial class ExecCredentialResponseContext : JsonSerializerContext + { + } +} diff --git a/src/KubernetesClient.Aot/KubeConfigModels/ExternalExecution.cs b/src/KubernetesClient.Aot/KubeConfigModels/ExternalExecution.cs new file mode 100644 index 000000000..7e18f449e --- /dev/null +++ b/src/KubernetesClient.Aot/KubeConfigModels/ExternalExecution.cs @@ -0,0 +1,42 @@ +using YamlDotNet.Serialization; + +namespace k8s.KubeConfigModels +{ + [YamlSerializable] + public class ExternalExecution + { + [YamlMember(Alias = "apiVersion")] + public string ApiVersion { get; set; } + + /// + /// The command to execute. Required. + /// + [YamlMember(Alias = "command")] + public string Command { get; set; } + + /// + /// Environment variables to set when executing the plugin. Optional. + /// + [YamlMember(Alias = "env")] + public IList> EnvironmentVariables { get; set; } + + /// + /// Arguments to pass when executing the plugin. Optional. + /// + [YamlMember(Alias = "args")] + public IList Arguments { get; set; } + + /// + /// Text shown to the user when the executable doesn't seem to be present. Optional. + /// + [YamlMember(Alias = "installHint")] + public string InstallHint { get; set; } + + /// + /// Whether or not to provide cluster information to this exec plugin as a part of + /// the KUBERNETES_EXEC_INFO environment variable. Optional. + /// + [YamlMember(Alias = "provideClusterInfo")] + public bool ProvideClusterInfo { get; set; } + } +} diff --git a/src/KubernetesClient.Aot/KubeConfigModels/K8SConfiguration.cs b/src/KubernetesClient.Aot/KubeConfigModels/K8SConfiguration.cs new file mode 100644 index 000000000..a0c3a4fef --- /dev/null +++ b/src/KubernetesClient.Aot/KubeConfigModels/K8SConfiguration.cs @@ -0,0 +1,65 @@ +using YamlDotNet.Serialization; + +namespace k8s.KubeConfigModels +{ + /// + /// kubeconfig configuration model. Holds the information needed to build connect to remote + /// Kubernetes clusters as a given user. + /// + /// + /// Should be kept in sync with https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/client-go/tools/clientcmd/api/v1/types.go + /// Should update MergeKubeConfig in KubernetesClientConfiguration.ConfigFile.cs if updated. + /// + [YamlSerializable] + public class K8SConfiguration + { + // /// + // /// Gets or sets general information to be use for CLI interactions + // /// + // [YamlMember(Alias = "preferences")] + // public IDictionary Preferences { get; set; } + + [YamlMember(Alias = "apiVersion")] + public string ApiVersion { get; set; } + + [YamlMember(Alias = "kind")] + public string Kind { get; set; } + + /// + /// Gets or sets the name of the context that you would like to use by default. + /// + [YamlMember(Alias = "current-context", ApplyNamingConventions = false)] + public string CurrentContext { get; set; } + + /// + /// Gets or sets a map of referencable names to context configs. + /// + [YamlMember(Alias = "contexts")] + public List Contexts { get; set; } = new List(); + + /// + /// Gets or sets a map of referencable names to cluster configs. + /// + [YamlMember(Alias = "clusters")] + public List Clusters { get; set; } = new List(); + + /// + /// Gets or sets a map of referencable names to user configs + /// + [YamlMember(Alias = "users")] + public List Users { get; set; } = new List(); + + // /// + // /// Gets or sets additional information. This is useful for extenders so that reads and writes don't clobber unknown fields. + // /// + // [YamlMember(Alias = "extensions")] + // public List Extensions { get; set; } + + /// + /// Gets or sets the name of the Kubernetes configuration file. This property is set only when the configuration + /// was loaded from disk, and can be used to resolve relative paths. + /// + [YamlIgnore] + public string FileName { get; set; } + } +} diff --git a/src/KubernetesClient.Aot/KubeConfigModels/StaticContext.cs b/src/KubernetesClient.Aot/KubeConfigModels/StaticContext.cs new file mode 100644 index 000000000..ae9be922e --- /dev/null +++ b/src/KubernetesClient.Aot/KubeConfigModels/StaticContext.cs @@ -0,0 +1,8 @@ +using YamlDotNet.Serialization; + +namespace k8s.KubeConfigModels; + +[YamlStaticContext] +public partial class StaticContext : YamlDotNet.Serialization.StaticContext +{ +} \ No newline at end of file diff --git a/src/KubernetesClient.Aot/KubeConfigModels/User.cs b/src/KubernetesClient.Aot/KubeConfigModels/User.cs new file mode 100644 index 000000000..557f02256 --- /dev/null +++ b/src/KubernetesClient.Aot/KubeConfigModels/User.cs @@ -0,0 +1,23 @@ +using YamlDotNet.Serialization; + +namespace k8s.KubeConfigModels +{ + /// + /// Relates nicknames to auth information. + /// + [YamlSerializable] + public class User + { + /// + /// Gets or sets the auth information. + /// + [YamlMember(Alias = "user")] + public UserCredentials UserCredentials { get; set; } + + /// + /// Gets or sets the nickname for this auth information. + /// + [YamlMember(Alias = "name")] + public string Name { get; set; } + } +} diff --git a/src/KubernetesClient.Aot/KubeConfigModels/UserCredentials.cs b/src/KubernetesClient.Aot/KubeConfigModels/UserCredentials.cs new file mode 100644 index 000000000..bd8a5063e --- /dev/null +++ b/src/KubernetesClient.Aot/KubeConfigModels/UserCredentials.cs @@ -0,0 +1,83 @@ +using YamlDotNet.Serialization; + +namespace k8s.KubeConfigModels +{ + /// + /// Contains information that describes identity information. This is use to tell the kubernetes cluster who you are. + /// + [YamlSerializable] + public class UserCredentials + { + /// + /// Gets or sets PEM-encoded data from a client cert file for TLS. Overrides . + /// + [YamlMember(Alias = "client-certificate-data", ApplyNamingConventions = false)] + public string ClientCertificateData { get; set; } + + /// + /// Gets or sets the path to a client cert file for TLS. + /// + [YamlMember(Alias = "client-certificate", ApplyNamingConventions = false)] + public string ClientCertificate { get; set; } + + /// + /// Gets or sets PEM-encoded data from a client key file for TLS. Overrides . + /// + [YamlMember(Alias = "client-key-data", ApplyNamingConventions = false)] + public string ClientKeyData { get; set; } + + /// + /// Gets or sets the path to a client key file for TLS. + /// + [YamlMember(Alias = "client-key", ApplyNamingConventions = false)] + public string ClientKey { get; set; } + + /// + /// Gets or sets the bearer token for authentication to the kubernetes cluster. + /// + [YamlMember(Alias = "token")] + public string Token { get; set; } + + /// + /// Gets or sets the username to impersonate. The name matches the flag. + /// + [YamlMember(Alias = "as")] + public string Impersonate { get; set; } + + /// + /// Gets or sets the groups to impersonate. + /// + [YamlMember(Alias = "as-groups", ApplyNamingConventions = false)] + public IEnumerable ImpersonateGroups { get; set; } = new string[0]; + + /// + /// Gets or sets additional information for impersonated user. + /// + [YamlMember(Alias = "as-user-extra", ApplyNamingConventions = false)] + public Dictionary ImpersonateUserExtra { get; set; } = new Dictionary(); + + /// + /// Gets or sets the username for basic authentication to the kubernetes cluster. + /// + [YamlMember(Alias = "username")] + public string UserName { get; set; } + + /// + /// Gets or sets the password for basic authentication to the kubernetes cluster. + /// + [YamlMember(Alias = "password")] + public string Password { get; set; } + + /// + /// Gets or sets custom authentication plugin for the kubernetes cluster. + /// + [YamlMember(Alias = "auth-provider", ApplyNamingConventions = false)] + public AuthProvider AuthProvider { get; set; } + + /// + /// Gets or sets external command and its arguments to receive user credentials + /// + [YamlMember(Alias = "exec")] + public ExternalExecution ExternalExecution { get; set; } + } +} diff --git a/src/KubernetesClient.Aot/KubernetesClient.Aot.csproj b/src/KubernetesClient.Aot/KubernetesClient.Aot.csproj new file mode 100644 index 000000000..5c7cf8fed --- /dev/null +++ b/src/KubernetesClient.Aot/KubernetesClient.Aot.csproj @@ -0,0 +1,113 @@ + + + + net8.0;net9.0 + k8s + true + true + true + $(DefineConstants);K8S_AOT + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/KubernetesClient.Aot/KubernetesClientConfiguration.ConfigFile.cs b/src/KubernetesClient.Aot/KubernetesClientConfiguration.ConfigFile.cs new file mode 100644 index 000000000..a2301b464 --- /dev/null +++ b/src/KubernetesClient.Aot/KubernetesClientConfiguration.ConfigFile.cs @@ -0,0 +1,774 @@ +using k8s.Authentication; +using k8s.Exceptions; +using k8s.KubeConfigModels; +using System.Diagnostics; +using System.Net; +using System.Runtime.InteropServices; +using System.Security.Cryptography.X509Certificates; + +namespace k8s +{ + public partial class KubernetesClientConfiguration + { + /// + /// kubeconfig Default Location + /// + public static readonly string KubeConfigDefaultLocation = + RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + ? Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE") ?? @"\", @".kube\config") + : Path.Combine(Environment.GetEnvironmentVariable("HOME") ?? "/", ".kube/config"); + + /// + /// Gets CurrentContext + /// + public string CurrentContext { get; private set; } + + // For testing + internal static string KubeConfigEnvironmentVariable { get; set; } = "KUBECONFIG"; + + /// + /// Exec process timeout + /// + public static TimeSpan ExecTimeout { get; set; } = TimeSpan.FromMinutes(2); + + /// + /// Exec process Standard Errors + /// + public static event EventHandler ExecStdError; + + /// + /// Initializes a new instance of the from default locations + /// If the KUBECONFIG environment variable is set, then that will be used. + /// Next, it looks for a config file at . + /// Then, it checks whether it is executing inside a cluster and will use . + /// Finally, if nothing else exists, it creates a default config with localhost:8080 as host. + /// + /// + /// If multiple kubeconfig files are specified in the KUBECONFIG environment variable, + /// merges the files, where first occurrence wins. See https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#merging-kubeconfig-files. + /// + /// Instance of the class + public static KubernetesClientConfiguration BuildDefaultConfig() + { + var kubeconfig = Environment.GetEnvironmentVariable(KubeConfigEnvironmentVariable); + if (kubeconfig != null) + { + var configList = kubeconfig.Split(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ';' : ':') + .Select((s) => new FileInfo(s.Trim('"'))); + var k8sConfig = LoadKubeConfig(configList.ToArray()); + return BuildConfigFromConfigObject(k8sConfig); + } + + if (File.Exists(KubeConfigDefaultLocation)) + { + return BuildConfigFromConfigFile(KubeConfigDefaultLocation); + } + + if (IsInCluster()) + { + return InClusterConfig(); + } + + var config = new KubernetesClientConfiguration + { + Host = "http://localhost:8080/", + }; + + return config; + } + + /// + /// Initializes a new instance of the from config file + /// + /// Explicit file path to kubeconfig. Set to null to use the default file path + /// override the context in config file, set null if do not want to override + /// kube api server endpoint + /// When , the paths in the kubeconfig file will be considered to be relative to the directory in which the kubeconfig + /// file is located. When , the paths will be considered to be relative to the current working directory. + /// Instance of the class + public static KubernetesClientConfiguration BuildConfigFromConfigFile( + string kubeconfigPath = null, + string currentContext = null, string masterUrl = null, bool useRelativePaths = true) + { + return BuildConfigFromConfigFile(new FileInfo(kubeconfigPath ?? KubeConfigDefaultLocation), currentContext, + masterUrl, useRelativePaths); + } + + /// + /// Initializes a new instance of the from config file + /// + /// Fileinfo of the kubeconfig, cannot be null + /// override the context in config file, set null if do not want to override + /// override the kube api server endpoint, set null if do not want to override + /// When , the paths in the kubeconfig file will be considered to be relative to the directory in which the kubeconfig + /// file is located. When , the paths will be considered to be relative to the current working directory. + /// Instance of the class + public static KubernetesClientConfiguration BuildConfigFromConfigFile( + FileInfo kubeconfig, + string currentContext = null, string masterUrl = null, bool useRelativePaths = true) + { + return BuildConfigFromConfigFileAsync(kubeconfig, currentContext, masterUrl, useRelativePaths).GetAwaiter() + .GetResult(); + } + + /// + /// Initializes a new instance of the from config file + /// + /// Fileinfo of the kubeconfig, cannot be null + /// override the context in config file, set null if do not want to override + /// override the kube api server endpoint, set null if do not want to override + /// When , the paths in the kubeconfig file will be considered to be relative to the directory in which the kubeconfig + /// file is located. When , the paths will be considered to be relative to the current working directory. + /// Instance of the class + public static async Task BuildConfigFromConfigFileAsync( + FileInfo kubeconfig, + string currentContext = null, string masterUrl = null, bool useRelativePaths = true) + { + if (kubeconfig == null) + { + throw new NullReferenceException(nameof(kubeconfig)); + } + + var k8SConfig = await LoadKubeConfigAsync(kubeconfig, useRelativePaths).ConfigureAwait(false); + var k8SConfiguration = GetKubernetesClientConfiguration(currentContext, masterUrl, k8SConfig); + + return k8SConfiguration; + } + + /// + /// Initializes a new instance of the from config file + /// + /// Stream of the kubeconfig, cannot be null + /// Override the current context in config, set null if do not want to override + /// Override the Kubernetes API server endpoint, set null if do not want to override + /// Instance of the class + public static KubernetesClientConfiguration BuildConfigFromConfigFile( + Stream kubeconfig, + string currentContext = null, string masterUrl = null) + { + return BuildConfigFromConfigFileAsync(kubeconfig, currentContext, masterUrl).GetAwaiter().GetResult(); + } + + /// + /// Initializes a new instance of the from config file + /// + /// Stream of the kubeconfig, cannot be null + /// Override the current context in config, set null if do not want to override + /// Override the Kubernetes API server endpoint, set null if do not want to override + /// Instance of the class + public static async Task BuildConfigFromConfigFileAsync( + Stream kubeconfig, + string currentContext = null, string masterUrl = null) + { + if (kubeconfig == null) + { + throw new NullReferenceException(nameof(kubeconfig)); + } + + if (!kubeconfig.CanSeek) + { + throw new Exception("Stream don't support seeking!"); + } + + kubeconfig.Position = 0; + + var k8SConfig = await KubernetesYaml.LoadFromStreamAsync(kubeconfig).ConfigureAwait(false); + var k8SConfiguration = GetKubernetesClientConfiguration(currentContext, masterUrl, k8SConfig); + + return k8SConfiguration; + } + + /// + /// Initializes a new instance of from pre-loaded config object. + /// + /// A , for example loaded from + /// Override the current context in config, set null if do not want to override + /// Override the Kubernetes API server endpoint, set null if do not want to override + /// Instance of the class + public static KubernetesClientConfiguration BuildConfigFromConfigObject( + K8SConfiguration k8SConfig, + string currentContext = null, string masterUrl = null) + => GetKubernetesClientConfiguration(currentContext, masterUrl, k8SConfig); + + private static KubernetesClientConfiguration GetKubernetesClientConfiguration( + string currentContext, + string masterUrl, K8SConfiguration k8SConfig) + { + if (k8SConfig == null) + { + throw new ArgumentNullException(nameof(k8SConfig)); + } + + var k8SConfiguration = new KubernetesClientConfiguration(); + + currentContext = currentContext ?? k8SConfig.CurrentContext; + // only init context if context is set + if (currentContext != null) + { + k8SConfiguration.InitializeContext(k8SConfig, currentContext); + } + + if (!string.IsNullOrWhiteSpace(masterUrl)) + { + k8SConfiguration.Host = masterUrl; + } + + if (string.IsNullOrWhiteSpace(k8SConfiguration.Host)) + { + throw new KubeConfigException("Cannot infer server host url either from context or masterUrl"); + } + + return k8SConfiguration; + } + + /// + /// Validates and Initializes Client Configuration + /// + /// Kubernetes Configuration + /// Current Context + private void InitializeContext(K8SConfiguration k8SConfig, string currentContext) + { + // current context + var activeContext = + k8SConfig.Contexts.FirstOrDefault( + c => c.Name.Equals(currentContext, StringComparison.OrdinalIgnoreCase)); + if (activeContext == null) + { + throw new KubeConfigException($"CurrentContext: {currentContext} not found in contexts in kubeconfig"); + } + + if (string.IsNullOrEmpty(activeContext.ContextDetails?.Cluster)) + { + // This serves as validation for any of the properties of ContextDetails being set. + // Other locations in code assume that ContextDetails is non-null. + throw new KubeConfigException($"Cluster not set for context `{currentContext}` in kubeconfig"); + } + + CurrentContext = activeContext.Name; + + // cluster + SetClusterDetails(k8SConfig, activeContext); + + // user + SetUserDetails(k8SConfig, activeContext); + + // namespace + Namespace = activeContext.ContextDetails?.Namespace; + } + + private void SetClusterDetails(K8SConfiguration k8SConfig, Context activeContext) + { + var clusterDetails = + k8SConfig.Clusters.FirstOrDefault(c => c.Name.Equals( + activeContext.ContextDetails.Cluster, + StringComparison.OrdinalIgnoreCase)); + + if (clusterDetails?.ClusterEndpoint == null) + { + throw new KubeConfigException($"Cluster not found for context `{activeContext}` in kubeconfig"); + } + + if (string.IsNullOrWhiteSpace(clusterDetails.ClusterEndpoint.Server)) + { + throw new KubeConfigException($"Server not found for current-context `{activeContext}` in kubeconfig"); + } + + Host = clusterDetails.ClusterEndpoint.Server; + SkipTlsVerify = clusterDetails.ClusterEndpoint.SkipTlsVerify; + TlsServerName = clusterDetails.ClusterEndpoint.TlsServerName; + + if (!Uri.TryCreate(Host, UriKind.Absolute, out var uri)) + { + throw new KubeConfigException($"Bad server host URL `{Host}` (cannot be parsed)"); + } + + if (IPAddress.TryParse(uri.Host, out var ipAddress)) + { + if (IPAddress.Equals(IPAddress.Any, ipAddress)) + { + var builder = new UriBuilder(Host) + { + Host = $"{IPAddress.Loopback}", + }; + Host = builder.ToString(); + } + else if (IPAddress.Equals(IPAddress.IPv6Any, ipAddress)) + { + var builder = new UriBuilder(Host) + { + Host = $"{IPAddress.IPv6Loopback}", + }; + Host = builder.ToString(); + } + } + + if (uri.Scheme == "https") + { + if (!string.IsNullOrEmpty(clusterDetails.ClusterEndpoint.CertificateAuthorityData)) + { + var data = clusterDetails.ClusterEndpoint.CertificateAuthorityData; +#if NET9_0_OR_GREATER + SslCaCerts = new X509Certificate2Collection(X509CertificateLoader.LoadCertificate(Convert.FromBase64String(data))); +#else + string nullPassword = null; + // This null password is to change the constructor to fix this KB: + // https://support.microsoft.com/en-us/topic/kb5025823-change-in-how-net-applications-import-x-509-certificates-bf81c936-af2b-446e-9f7a-016f4713b46b + SslCaCerts = new X509Certificate2Collection(new X509Certificate2(Convert.FromBase64String(data), nullPassword)); +#endif + } + else if (!string.IsNullOrEmpty(clusterDetails.ClusterEndpoint.CertificateAuthority)) + { +#if NET9_0_OR_GREATER + SslCaCerts = new X509Certificate2Collection(X509CertificateLoader.LoadCertificateFromFile(GetFullPath( + k8SConfig, + clusterDetails.ClusterEndpoint.CertificateAuthority))); +#else + SslCaCerts = new X509Certificate2Collection(new X509Certificate2(GetFullPath( + k8SConfig, + clusterDetails.ClusterEndpoint.CertificateAuthority))); +#endif + } + } + } + + + private void SetUserDetails(K8SConfiguration k8SConfig, Context activeContext) + { + if (string.IsNullOrWhiteSpace(activeContext.ContextDetails.User)) + { + return; + } + + var userDetails = k8SConfig.Users.FirstOrDefault(c => c.Name.Equals( + activeContext.ContextDetails.User, + StringComparison.OrdinalIgnoreCase)); + + if (userDetails == null) + { + throw new KubeConfigException($"User not found for context {activeContext.Name} in kubeconfig"); + } + + if (userDetails.UserCredentials == null) + { + throw new KubeConfigException($"User credentials not found for user: {userDetails.Name} in kubeconfig"); + } + + var userCredentialsFound = false; + + // Basic and bearer tokens are mutually exclusive + if (!string.IsNullOrWhiteSpace(userDetails.UserCredentials.Token)) + { + AccessToken = userDetails.UserCredentials.Token; + userCredentialsFound = true; + } + else if (!string.IsNullOrWhiteSpace(userDetails.UserCredentials.UserName) && + !string.IsNullOrWhiteSpace(userDetails.UserCredentials.Password)) + { + Username = userDetails.UserCredentials.UserName; + Password = userDetails.UserCredentials.Password; + userCredentialsFound = true; + } + + // Token and cert based auth can co-exist + if (!string.IsNullOrWhiteSpace(userDetails.UserCredentials.ClientCertificateData) && + !string.IsNullOrWhiteSpace(userDetails.UserCredentials.ClientKeyData)) + { + ClientCertificateData = userDetails.UserCredentials.ClientCertificateData; + ClientCertificateKeyData = userDetails.UserCredentials.ClientKeyData; + userCredentialsFound = true; + } + + if (!string.IsNullOrWhiteSpace(userDetails.UserCredentials.ClientCertificate) && + !string.IsNullOrWhiteSpace(userDetails.UserCredentials.ClientKey)) + { + ClientCertificateFilePath = GetFullPath(k8SConfig, userDetails.UserCredentials.ClientCertificate); + ClientKeyFilePath = GetFullPath(k8SConfig, userDetails.UserCredentials.ClientKey); + userCredentialsFound = true; + } + + if (userDetails.UserCredentials.AuthProvider != null) + { + if (userDetails.UserCredentials.AuthProvider.Config != null + && (userDetails.UserCredentials.AuthProvider.Config.ContainsKey("access-token") + || userDetails.UserCredentials.AuthProvider.Config.ContainsKey("id-token"))) + { + switch (userDetails.UserCredentials.AuthProvider.Name) + { + case "azure": + throw new Exception("Please use the https://github.com/Azure/kubelogin credential plugin instead. See https://kubernetes.io/docs/reference/access-authn-authz/authentication/#client-go-credential-plugins for further details`"); + + case "gcp": + throw new Exception("Please use the \"gke-gcloud-auth-plugin\" credential plugin instead. See https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke for further details"); + } + } + } + + if (userDetails.UserCredentials.ExternalExecution != null) + { + if (string.IsNullOrWhiteSpace(userDetails.UserCredentials.ExternalExecution.Command)) + { + throw new KubeConfigException( + "External command execution to receive user credentials must include a command to execute"); + } + + if (string.IsNullOrWhiteSpace(userDetails.UserCredentials.ExternalExecution.ApiVersion)) + { + throw new KubeConfigException("External command execution missing ApiVersion key"); + } + + var response = ExecuteExternalCommand(userDetails.UserCredentials.ExternalExecution); + AccessToken = response.Status.Token; + // When reading ClientCertificateData from a config file it will be base64 encoded, and code later in the system (see CertUtils.GeneratePfx) + // expects ClientCertificateData and ClientCertificateKeyData to be base64 encoded because of this. However the string returned by external + // auth providers is the raw certificate and key PEM text, so we need to take that and base64 encoded it here so it can be decoded later. + ClientCertificateData = response.Status.ClientCertificateData == null ? null : Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(response.Status.ClientCertificateData)); + ClientCertificateKeyData = response.Status.ClientKeyData == null ? null : Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(response.Status.ClientKeyData)); + + userCredentialsFound = true; + + // TODO: support client certificates here too. + if (AccessToken != null) + { + TokenProvider = new ExecTokenProvider(userDetails.UserCredentials.ExternalExecution); + } + } + + if (!userCredentialsFound) + { + throw new KubeConfigException( + $"User: {userDetails.Name} does not have appropriate auth credentials in kubeconfig"); + } + } + + public static Process CreateRunnableExternalProcess(ExternalExecution config, EventHandler captureStdError = null) + { + if (config == null) + { + throw new ArgumentNullException(nameof(config)); + } + + var process = new Process(); + + process.StartInfo.EnvironmentVariables.Add("KUBERNETES_EXEC_INFO", $"{{ \"apiVersion\":\"{config.ApiVersion}\",\"kind\":\"ExecCredentials\",\"spec\":{{ \"interactive\":{Environment.UserInteractive.ToString().ToLower()} }} }}"); + if (config.EnvironmentVariables != null) + { + foreach (var configEnvironmentVariable in config.EnvironmentVariables) + { + if (configEnvironmentVariable.ContainsKey("name") && configEnvironmentVariable.ContainsKey("value")) + { + var name = configEnvironmentVariable["name"]; + process.StartInfo.EnvironmentVariables[name] = configEnvironmentVariable["value"]; + } + else + { + var badVariable = string.Join(",", configEnvironmentVariable.Select(x => $"{x.Key}={x.Value}")); + throw new KubeConfigException($"Invalid environment variable defined: {badVariable}"); + } + } + } + + process.StartInfo.FileName = config.Command; + if (config.Arguments != null) + { + process.StartInfo.Arguments = string.Join(" ", config.Arguments); + } + + process.StartInfo.RedirectStandardOutput = true; + process.StartInfo.RedirectStandardError = captureStdError != null; + process.StartInfo.UseShellExecute = false; + process.StartInfo.CreateNoWindow = true; + + return process; + } + + /// + /// Implementation of the proposal for out-of-tree client + /// authentication providers as described here -- + /// https://github.com/kubernetes/community/blob/master/contributors/design-proposals/auth/kubectl-exec-plugins.md + /// Took inspiration from python exec_provider.py -- + /// https://github.com/kubernetes-client/python-base/blob/master/config/exec_provider.py + /// + /// The external command execution configuration + /// + /// The token, client certificate data, and the client key data received from the external command execution + /// + public static ExecCredentialResponse ExecuteExternalCommand(ExternalExecution config) + { + if (config == null) + { + throw new ArgumentNullException(nameof(config)); + } + + var captureStdError = ExecStdError; + var process = CreateRunnableExternalProcess(config, captureStdError); + + try + { + process.Start(); + if (captureStdError != null) + { + process.ErrorDataReceived += captureStdError.Invoke; + process.BeginErrorReadLine(); + } + } + catch (Exception ex) + { + throw new KubeConfigException($"external exec failed due to: {ex.Message}"); + } + + try + { + if (!process.WaitForExit((int)(ExecTimeout.TotalMilliseconds))) + { + throw new KubeConfigException("external exec failed due to timeout"); + } + + var responseObject = JsonSerializer.Deserialize( + process.StandardOutput.ReadToEnd(), + ExecCredentialResponseContext.Default.ExecCredentialResponse); + + if (responseObject == null || responseObject.ApiVersion != config.ApiVersion) + { + throw new KubeConfigException( + $"external exec failed because api version {responseObject.ApiVersion} does not match {config.ApiVersion}"); + } + + if (responseObject.Status.IsValid()) + { + return responseObject; + } + else + { + throw new KubeConfigException($"external exec failed missing token or clientCertificateData field in plugin output"); + } + } + catch (JsonException ex) + { + throw new KubeConfigException($"external exec failed due to failed deserialization process: {ex}"); + } + catch (Exception ex) + { + throw new KubeConfigException($"external exec failed due to uncaught exception: {ex}"); + } + } + + /// + /// Loads entire Kube Config from default or explicit file path + /// + /// Explicit file path to kubeconfig. Set to null to use the default file path + /// When , the paths in the kubeconfig file will be considered to be relative to the directory in which the kubeconfig + /// file is located. When , the paths will be considered to be relative to the current working directory. + /// Instance of the class + public static async Task LoadKubeConfigAsync( + string kubeconfigPath = null, + bool useRelativePaths = true) + { + var fileInfo = new FileInfo(kubeconfigPath ?? KubeConfigDefaultLocation); + + return await LoadKubeConfigAsync(fileInfo, useRelativePaths).ConfigureAwait(false); + } + + /// + /// Loads entire Kube Config from default or explicit file path + /// + /// Explicit file path to kubeconfig. Set to null to use the default file path + /// When , the paths in the kubeconfig file will be considered to be relative to the directory in which the kubeconfig + /// file is located. When , the paths will be considered to be relative to the current working directory. + /// Instance of the class + public static K8SConfiguration LoadKubeConfig(string kubeconfigPath = null, bool useRelativePaths = true) + { + return LoadKubeConfigAsync(kubeconfigPath, useRelativePaths).GetAwaiter().GetResult(); + } + + /// + /// Loads Kube Config + /// + /// Kube config file contents + /// When , the paths in the kubeconfig file will be considered to be relative to the directory in which the kubeconfig + /// file is located. When , the paths will be considered to be relative to the current working directory. + /// Instance of the class + public static async Task LoadKubeConfigAsync( + FileInfo kubeconfig, + bool useRelativePaths = true) + { + if (kubeconfig == null) + { + throw new ArgumentNullException(nameof(kubeconfig)); + } + + + if (!kubeconfig.Exists) + { + throw new KubeConfigException($"kubeconfig file not found at {kubeconfig.FullName}"); + } + + using (var stream = kubeconfig.OpenRead()) + { + var config = await KubernetesYaml.LoadFromStreamAsync(stream).ConfigureAwait(false); + + if (useRelativePaths) + { + config.FileName = kubeconfig.FullName; + } + + return config; + } + } + + /// + /// Loads Kube Config + /// + /// Kube config file contents + /// When , the paths in the kubeconfig file will be considered to be relative to the directory in which the kubeconfig + /// file is located. When , the paths will be considered to be relative to the current working directory. + /// Instance of the class + public static K8SConfiguration LoadKubeConfig(FileInfo kubeconfig, bool useRelativePaths = true) + { + return LoadKubeConfigAsync(kubeconfig, useRelativePaths).GetAwaiter().GetResult(); + } + + /// + /// Loads Kube Config + /// + /// Kube config file contents stream + /// Instance of the class + public static async Task LoadKubeConfigAsync(Stream kubeconfigStream) + { + return await KubernetesYaml.LoadFromStreamAsync(kubeconfigStream).ConfigureAwait(false); + } + + /// + /// Loads Kube Config + /// + /// Kube config file contents stream + /// Instance of the class + public static K8SConfiguration LoadKubeConfig(Stream kubeconfigStream) + { + return LoadKubeConfigAsync(kubeconfigStream).GetAwaiter().GetResult(); + } + + /// + /// Loads Kube Config + /// + /// List of kube config file contents + /// When , the paths in the kubeconfig file will be considered to be relative to the directory in which the kubeconfig + /// file is located. When , the paths will be considered to be relative to the current working directory. + /// Instance of the class + /// + /// The kube config files will be merges into a single , where first occurrence wins. + /// See https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#merging-kubeconfig-files. + /// + internal static K8SConfiguration LoadKubeConfig(FileInfo[] kubeConfigs, bool useRelativePaths = true) + { + return LoadKubeConfigAsync(kubeConfigs, useRelativePaths).GetAwaiter().GetResult(); + } + + /// + /// Loads Kube Config + /// + /// List of kube config file contents + /// When , the paths in the kubeconfig file will be considered to be relative to the directory in which the kubeconfig + /// file is located. When , the paths will be considered to be relative to the current working directory. + /// Instance of the class + /// + /// The kube config files will be merges into a single , where first occurrence wins. + /// See https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#merging-kubeconfig-files. + /// + internal static async Task LoadKubeConfigAsync( + FileInfo[] kubeConfigs, + bool useRelativePaths = true) + { + var basek8SConfig = await LoadKubeConfigAsync(kubeConfigs[0], useRelativePaths).ConfigureAwait(false); + + for (var i = 1; i < kubeConfigs.Length; i++) + { + var mergek8SConfig = await LoadKubeConfigAsync(kubeConfigs[i], useRelativePaths).ConfigureAwait(false); + MergeKubeConfig(basek8SConfig, mergek8SConfig); + } + + return basek8SConfig; + } + + /// + /// Tries to get the full path to a file referenced from the Kubernetes configuration. + /// + /// + /// The Kubernetes configuration. + /// + /// + /// The path to resolve. + /// + /// + /// When possible a fully qualified path to the file. + /// + /// + /// For example, if the configuration file is at "C:\Users\me\kube.config" and path is "ca.crt", + /// this will return "C:\Users\me\ca.crt". Similarly, if path is "D:\ca.cart", this will return + /// "D:\ca.crt". + /// + private static string GetFullPath(K8SConfiguration configuration, string path) + { + // If we don't have a file name, + if (string.IsNullOrWhiteSpace(configuration.FileName) || Path.IsPathRooted(path)) + { + return path; + } + else + { + return Path.Combine(Path.GetDirectoryName(configuration.FileName), path); + } + } + + /// + /// Merges kube config files together, preferring configuration present in the base config over the merge config. + /// + /// The to merge into + /// The to merge from + private static void MergeKubeConfig(K8SConfiguration basek8SConfig, K8SConfiguration mergek8SConfig) + { + // For scalar values, prefer local values + basek8SConfig.CurrentContext = basek8SConfig.CurrentContext ?? mergek8SConfig.CurrentContext; + basek8SConfig.FileName = basek8SConfig.FileName ?? mergek8SConfig.FileName; + + // Kinds must match in kube config, otherwise throw. + if (basek8SConfig.Kind != mergek8SConfig.Kind) + { + throw new KubeConfigException( + $"kubeconfig \"kind\" are different between {basek8SConfig.FileName} and {mergek8SConfig.FileName}"); + } + + // Note, Clusters, Contexts, and Extensions are map-like in config despite being represented as a list here: + // https://github.com/kubernetes/client-go/blob/ede92e0fe62deed512d9ceb8bf4186db9f3776ff/tools/clientcmd/api/types.go#L238 + // basek8SConfig.Extensions = MergeLists(basek8SConfig.Extensions, mergek8SConfig.Extensions, (s) => s.Name).ToList(); + basek8SConfig.Clusters = MergeLists(basek8SConfig.Clusters, mergek8SConfig.Clusters, (s) => s.Name).ToList(); + basek8SConfig.Users = MergeLists(basek8SConfig.Users, mergek8SConfig.Users, (s) => s.Name).ToList(); + basek8SConfig.Contexts = MergeLists(basek8SConfig.Contexts, mergek8SConfig.Contexts, (s) => s.Name).ToList(); + } + + private static IEnumerable MergeLists(IEnumerable baseList, IEnumerable mergeList, + Func getNameFunc) + { + if (mergeList != null && mergeList.Any()) + { + var mapping = new Dictionary(); + foreach (var item in baseList) + { + mapping[getNameFunc(item)] = item; + } + + foreach (var item in mergeList) + { + var name = getNameFunc(item); + if (!mapping.ContainsKey(name)) + { + mapping[name] = item; + } + } + + return mapping.Values; + } + + return baseList; + } + } +} diff --git a/src/KubernetesClient.Aot/KubernetesYaml.cs b/src/KubernetesClient.Aot/KubernetesYaml.cs new file mode 100644 index 000000000..5530a2e02 --- /dev/null +++ b/src/KubernetesClient.Aot/KubernetesYaml.cs @@ -0,0 +1,171 @@ +using System.Text; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; +using YamlDotNet.Serialization; +using YamlDotNet.Serialization.NamingConventions; + +namespace k8s +{ + /// + /// This is a utility class that helps you load objects from YAML files. + /// + internal static class KubernetesYaml + { + private static StaticDeserializerBuilder CommonDeserializerBuilder => + new StaticDeserializerBuilder(new k8s.KubeConfigModels.StaticContext()) + .WithNamingConvention(CamelCaseNamingConvention.Instance) + .WithTypeConverter(new IntOrStringYamlConverter()) + .WithTypeConverter(new ByteArrayStringYamlConverter()) + .WithTypeConverter(new ResourceQuantityYamlConverter()) + .WithTypeConverter(new KubernetesDateTimeYamlConverter()) + .WithTypeConverter(new KubernetesDateTimeOffsetYamlConverter()) + .WithAttemptingUnquotedStringTypeDeserialization() + ; + + private static readonly IDeserializer Deserializer = + CommonDeserializerBuilder + .IgnoreUnmatchedProperties() + .Build(); + private static IDeserializer GetDeserializer(bool strict) => Deserializer; + + private static readonly IValueSerializer Serializer = + new StaticSerializerBuilder(new k8s.KubeConfigModels.StaticContext()) + .DisableAliases() + .WithNamingConvention(CamelCaseNamingConvention.Instance) + .WithTypeConverter(new IntOrStringYamlConverter()) + .WithTypeConverter(new ByteArrayStringYamlConverter()) + .WithTypeConverter(new ResourceQuantityYamlConverter()) + .WithTypeConverter(new KubernetesDateTimeYamlConverter()) + .WithTypeConverter(new KubernetesDateTimeOffsetYamlConverter()) + .WithEventEmitter(e => new StringQuotingEmitter(e)) + .WithEventEmitter(e => new FloatEmitter(e)) + .ConfigureDefaultValuesHandling(DefaultValuesHandling.OmitNull) + .BuildValueSerializer(); + + private class ByteArrayStringYamlConverter : IYamlTypeConverter + { + public bool Accepts(Type type) + { + return type == typeof(byte[]); + } + + public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer) + { + if (parser?.Current is Scalar scalar) + { + try + { + if (string.IsNullOrEmpty(scalar.Value)) + { + return null; + } + + return Convert.FromBase64String(scalar.Value); + } + finally + { + parser.MoveNext(); + } + } + + throw new InvalidOperationException(parser.Current?.ToString()); + } + + public void WriteYaml(IEmitter emitter, object value, Type type, ObjectSerializer serializer) + { + if (value == null) + { + emitter.Emit(new Scalar(string.Empty)); + return; + } + + var obj = (byte[])value; + var encoded = Convert.ToBase64String(obj); + emitter.Emit(new Scalar(encoded)); + } + } + + public static async Task LoadFromStreamAsync(Stream stream, bool strict = false) + { + var reader = new StreamReader(stream); + var content = await reader.ReadToEndAsync().ConfigureAwait(false); + return Deserialize(content, strict); + } + + public static async Task LoadFromFileAsync(string file, bool strict = false) + { + using (var fs = File.OpenRead(file)) + { + return await LoadFromStreamAsync(fs, strict).ConfigureAwait(false); + } + } + + [Obsolete("use Deserialize")] + public static T LoadFromString(string content, bool strict = false) + { + return Deserialize(content, strict); + } + + [Obsolete("use Serialize")] + public static string SaveToString(T value) + { + return Serialize(value); + } + + public static TValue Deserialize(string yaml, bool strict = false) + { + using var reader = new StringReader(yaml); + return GetDeserializer(strict).Deserialize(new MergingParser(new Parser(reader))); + } + + public static TValue Deserialize(Stream yaml, bool strict = false) + { + using var reader = new StreamReader(yaml); + return GetDeserializer(strict).Deserialize(new MergingParser(new Parser(reader))); + } + + public static string SerializeAll(IEnumerable values) + { + if (values == null) + { + return ""; + } + + var stringBuilder = new StringBuilder(); + var writer = new StringWriter(stringBuilder); + var emitter = new Emitter(writer); + + emitter.Emit(new StreamStart()); + + foreach (var value in values) + { + if (value != null) + { + emitter.Emit(new DocumentStart()); + Serializer.SerializeValue(emitter, value, value.GetType()); + emitter.Emit(new DocumentEnd(true)); + } + } + + return stringBuilder.ToString(); + } + + public static string Serialize(object value) + { + if (value == null) + { + return ""; + } + + var stringBuilder = new StringBuilder(); + var writer = new StringWriter(stringBuilder); + var emitter = new Emitter(writer); + + emitter.Emit(new StreamStart()); + emitter.Emit(new DocumentStart()); + Serializer.SerializeValue(emitter, value, value.GetType()); + + return stringBuilder.ToString(); + } + } +} diff --git a/src/KubernetesClient.Aot/V1PatchJsonConverter.cs b/src/KubernetesClient.Aot/V1PatchJsonConverter.cs new file mode 100644 index 000000000..314ef5694 --- /dev/null +++ b/src/KubernetesClient.Aot/V1PatchJsonConverter.cs @@ -0,0 +1,29 @@ +namespace k8s.Models +{ +#pragma warning disable CA1812 // Avoid uninstantiated internal classes + internal sealed class V1PatchJsonConverter : JsonConverter +#pragma warning restore CA1812 // Avoid uninstantiated internal classes + { + public override V1Patch Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + throw new NotImplementedException(); + } + + public override void Write(Utf8JsonWriter writer, V1Patch value, JsonSerializerOptions options) + { + if (writer == null) + { + throw new ArgumentNullException(nameof(writer)); + } + + var content = value?.Content; + if (content is string s) + { + writer.WriteRawValue(s); + return; + } + + throw new NotSupportedException("only string json patch is supported"); + } + } +} diff --git a/src/KubernetesClient.Basic/AssemblyInfo.cs b/src/KubernetesClient.Basic/AssemblyInfo.cs deleted file mode 100644 index b13544f39..000000000 --- a/src/KubernetesClient.Basic/AssemblyInfo.cs +++ /dev/null @@ -1,5 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("KubernetesClient")] -[assembly: InternalsVisibleTo("KubernetesClient.Classic")] -[assembly: InternalsVisibleTo("KubernetesClient.Tests")] diff --git a/src/KubernetesClient.Basic/Autorest/RestException.cs b/src/KubernetesClient.Basic/Autorest/RestException.cs deleted file mode 100644 index d24730fab..000000000 --- a/src/KubernetesClient.Basic/Autorest/RestException.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -using System.Runtime.Serialization; - -namespace k8s.Autorest -{ - /// - /// Generic exception for Microsoft Rest Client. - /// - [Serializable] - public class RestException : Exception - { - /// - /// Initializes a new instance of the class. - /// - public RestException() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The exception message. - public RestException(string message) - : this(message, null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The exception message. - /// Inner exception. - public RestException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Serialization info. - /// Streaming context. - protected RestException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/src/KubernetesClient.Basic/GeneratedApiVersion.cs b/src/KubernetesClient.Basic/GeneratedApiVersion.cs deleted file mode 100644 index ab1d4d893..000000000 --- a/src/KubernetesClient.Basic/GeneratedApiVersion.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace k8s; - -public static class GeneratedApiVersion -{ - public const string AssemblyVersion = ThisAssembly.AssemblyInformationalVersion; - public const string SwaggerVersion = ThisAssembly.KubernetesSwaggerVersion; -} diff --git a/src/KubernetesClient.Basic/KubernetesClient.Basic.csproj b/src/KubernetesClient.Basic/KubernetesClient.Basic.csproj deleted file mode 100644 index 353630c34..000000000 --- a/src/KubernetesClient.Basic/KubernetesClient.Basic.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - netstandard2.0 - k8s - - - - - - - - - - - - - diff --git a/src/KubernetesClient.Classic/CertUtils.cs b/src/KubernetesClient.Classic/CertUtils.cs new file mode 100644 index 000000000..112ef922e --- /dev/null +++ b/src/KubernetesClient.Classic/CertUtils.cs @@ -0,0 +1,156 @@ +using k8s.Exceptions; +using Org.BouncyCastle.Asn1.Nist; +using Org.BouncyCastle.Asn1.Pkcs; +using Org.BouncyCastle.Crypto; +using Org.BouncyCastle.OpenSsl; +using Org.BouncyCastle.Pkcs; +using Org.BouncyCastle.Security; +using Org.BouncyCastle.X509; +using System.Security.Cryptography.X509Certificates; + +namespace k8s +{ + internal static class CertUtils + { + /// + /// Load pem encoded cert file + /// + /// Path to pem encoded cert file + /// List of x509 instances. + public static X509Certificate2Collection LoadPemFileCert(string file) + { + var certCollection = new X509Certificate2Collection(); + using (var stream = FileSystem.Current.OpenRead(file)) + { + var certs = new X509CertificateParser().ReadCertificates(stream); + + // Convert BouncyCastle X509Certificates to the .NET cryptography implementation and add + // it to the certificate collection + // + foreach (Org.BouncyCastle.X509.X509Certificate cert in certs) + { + // This null password is to change the constructor to fix this KB: + // https://support.microsoft.com/en-us/topic/kb5025823-change-in-how-net-applications-import-x-509-certificates-bf81c936-af2b-446e-9f7a-016f4713b46b + string nullPassword = null; + certCollection.Add(new X509Certificate2(cert.GetEncoded(), nullPassword)); + } + } + + return certCollection; + } + + /// + /// Generates pfx from client configuration + /// + /// Kubernetes Client Configuration + /// Generated Pfx Path + public static X509Certificate2 GeneratePfx(KubernetesClientConfiguration config) + { + if (config == null) + { + throw new ArgumentNullException(nameof(config)); + } + + byte[] keyData = null; + byte[] certData = null; + + if (!string.IsNullOrWhiteSpace(config.ClientCertificateKeyData)) + { + keyData = Convert.FromBase64String(config.ClientCertificateKeyData); + } + + if (!string.IsNullOrWhiteSpace(config.ClientKeyFilePath)) + { + keyData = File.ReadAllBytes(config.ClientKeyFilePath); + } + + if (keyData == null) + { + throw new KubeConfigException("keyData is empty"); + } + + if (!string.IsNullOrWhiteSpace(config.ClientCertificateData)) + { + certData = Convert.FromBase64String(config.ClientCertificateData); + } + + if (!string.IsNullOrWhiteSpace(config.ClientCertificateFilePath)) + { + certData = File.ReadAllBytes(config.ClientCertificateFilePath); + } + + if (certData == null) + { + throw new KubeConfigException("certData is empty"); + } + + var cert = new X509CertificateParser().ReadCertificate(new MemoryStream(certData)); + // key usage is a bit string, zero-th bit is 'digitalSignature' + // See https://www.alvestrand.no/objectid/2.5.29.15.html for more details. + if (cert != null && cert.GetKeyUsage() != null && !cert.GetKeyUsage()[0]) + { + throw new Exception( + "Client certificates must be marked for digital signing. " + + "See https://github.com/kubernetes-client/csharp/issues/319"); + } + + object obj; + using (var reader = new StreamReader(new MemoryStream(keyData))) + { + obj = new PemReader(reader).ReadObject(); + if (obj is AsymmetricCipherKeyPair key) + { + var cipherKey = key; + obj = cipherKey.Private; + } + } + + var keyParams = (AsymmetricKeyParameter)obj; + + var store = new Pkcs12StoreBuilder() + .SetKeyAlgorithm(NistObjectIdentifiers.IdAes128Cbc, PkcsObjectIdentifiers.IdHmacWithSha1) + .Build(); + store.SetKeyEntry("K8SKEY", new AsymmetricKeyEntry(keyParams), new[] { new X509CertificateEntry(cert) }); + + using var pkcs = new MemoryStream(); + + store.Save(pkcs, new char[0], new SecureRandom()); + + // This null password is to change the constructor to fix this KB: + // https://support.microsoft.com/en-us/topic/kb5025823-change-in-how-net-applications-import-x-509-certificates-bf81c936-af2b-446e-9f7a-016f4713b46b + string nullPassword = null; + + if (config.ClientCertificateKeyStoreFlags.HasValue) + { + return new X509Certificate2(pkcs.ToArray(), nullPassword, config.ClientCertificateKeyStoreFlags.Value); + } + else + { + return new X509Certificate2(pkcs.ToArray(), nullPassword); + } + } + + /// + /// Retrieves Client Certificate PFX from configuration + /// + /// Kubernetes Client Configuration + /// Client certificate PFX + public static X509Certificate2 GetClientCert(KubernetesClientConfiguration config) + { + if (config == null) + { + throw new ArgumentNullException(nameof(config)); + } + + if ((!string.IsNullOrWhiteSpace(config.ClientCertificateData) || + !string.IsNullOrWhiteSpace(config.ClientCertificateFilePath)) && + (!string.IsNullOrWhiteSpace(config.ClientCertificateKeyData) || + !string.IsNullOrWhiteSpace(config.ClientKeyFilePath))) + { + return GeneratePfx(config); + } + + return null; + } + } +} diff --git a/src/KubernetesClient.Classic/Global.cs b/src/KubernetesClient.Classic/Global.cs index f96593e4a..2b5a4ae8e 100644 --- a/src/KubernetesClient.Classic/Global.cs +++ b/src/KubernetesClient.Classic/Global.cs @@ -1,4 +1,10 @@ +global using k8s.Autorest; +global using k8s.Models; global using System; global using System.Collections.Generic; +global using System.IO; global using System.Linq; global using System.Text.Json; +global using System.Text.Json.Serialization; +global using System.Threading; +global using System.Threading.Tasks; diff --git a/src/KubernetesClient.Classic/IsExternalInit.cs b/src/KubernetesClient.Classic/IsExternalInit.cs new file mode 100644 index 000000000..749f30858 --- /dev/null +++ b/src/KubernetesClient.Classic/IsExternalInit.cs @@ -0,0 +1,5 @@ +// IntOrString.cs(7,36): error CS0518: Predefined type 'System.Runtime.CompilerServices.IsExternalInit' is not defined or imported +namespace System.Runtime.CompilerServices +{ + internal static class IsExternalInit { } +} \ No newline at end of file diff --git a/src/KubernetesClient.Classic/KubernetesClient.Classic.csproj b/src/KubernetesClient.Classic/KubernetesClient.Classic.csproj index 4b6f2d7bf..902dc41dd 100644 --- a/src/KubernetesClient.Classic/KubernetesClient.Classic.csproj +++ b/src/KubernetesClient.Classic/KubernetesClient.Classic.csproj @@ -6,20 +6,82 @@ - - - - + + + + + - + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + @@ -43,16 +105,28 @@ + + + + - + + + + + - + + + + + diff --git a/src/KubernetesClient.Kubectl/Beta/AsyncKubectl.Cordon.cs b/src/KubernetesClient.Kubectl/Beta/AsyncKubectl.Cordon.cs new file mode 100644 index 000000000..60ab97877 --- /dev/null +++ b/src/KubernetesClient.Kubectl/Beta/AsyncKubectl.Cordon.cs @@ -0,0 +1,30 @@ +using Json.Patch; +using k8s.Models; +using System.Text.Json; + +namespace k8s.kubectl.beta; + +public partial class AsyncKubectl +{ + public async Task Cordon(string nodeName, CancellationToken cancellationToken = default) + { + await PatchNodeUnschedulable(nodeName, true, cancellationToken).ConfigureAwait(false); + } + + public async Task Uncordon(string nodeName, CancellationToken cancellationToken = default) + { + await PatchNodeUnschedulable(nodeName, false, cancellationToken).ConfigureAwait(false); + } + + private async Task PatchNodeUnschedulable(string nodeName, bool desired, CancellationToken cancellationToken = default) + { + var node = await client.CoreV1.ReadNodeAsync(nodeName, cancellationToken: cancellationToken).ConfigureAwait(false); + + var old = JsonSerializer.SerializeToDocument(node); + node.Spec.Unschedulable = desired; + + var patch = old.CreatePatch(node); + + await client.CoreV1.PatchNodeAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), nodeName, cancellationToken: cancellationToken).ConfigureAwait(false); + } +} diff --git a/src/KubernetesClient.Kubectl/Beta/Kubectl.Cordon.cs b/src/KubernetesClient.Kubectl/Beta/Kubectl.Cordon.cs new file mode 100644 index 000000000..c1d85a531 --- /dev/null +++ b/src/KubernetesClient.Kubectl/Beta/Kubectl.Cordon.cs @@ -0,0 +1,14 @@ +namespace k8s.kubectl.beta; + +public partial class Kubectl +{ + public void Cordon(string nodeName) + { + client.Cordon(nodeName).GetAwaiter().GetResult(); + } + + public void Uncordon(string nodeName) + { + client.Uncordon(nodeName).GetAwaiter().GetResult(); + } +} diff --git a/src/KubernetesClient.Kubectl/KubernetesClient.Kubectl.csproj b/src/KubernetesClient.Kubectl/KubernetesClient.Kubectl.csproj index 794a3d87c..25440a1f7 100644 --- a/src/KubernetesClient.Kubectl/KubernetesClient.Kubectl.csproj +++ b/src/KubernetesClient.Kubectl/KubernetesClient.Kubectl.csproj @@ -1,12 +1,15 @@ - net6.0 + net8.0;net9.0 enable enable k8s.kubectl + + + diff --git a/src/KubernetesClient.Models/AssemblyInfo.cs b/src/KubernetesClient.Models/AssemblyInfo.cs deleted file mode 100644 index e3f8177b5..000000000 --- a/src/KubernetesClient.Models/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("KubernetesClient")] -[assembly: InternalsVisibleTo("KubernetesClient.Classic")] -[assembly: InternalsVisibleTo("KubernetesClient.Basic")] -[assembly: InternalsVisibleTo("KubernetesClient.Tests")] diff --git a/src/KubernetesClient.Models/Global.cs b/src/KubernetesClient.Models/Global.cs deleted file mode 100644 index 70b3700e1..000000000 --- a/src/KubernetesClient.Models/Global.cs +++ /dev/null @@ -1,5 +0,0 @@ -global using System; -global using System.Collections.Generic; -global using System.Linq; -global using System.Text.Json; -global using System.Text.Json.Serialization; diff --git a/src/KubernetesClient.Models/IItems.cs b/src/KubernetesClient.Models/IItems.cs deleted file mode 100644 index 408f77cb4..000000000 --- a/src/KubernetesClient.Models/IItems.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace k8s -{ - /// - /// Kubernetes object that exposes list of objects - /// - /// type of the objects - public interface IItems - { - /// - /// Gets or sets list of objects. More info: - /// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md - /// - IList Items { get; set; } - } -} diff --git a/src/KubernetesClient.Models/IMetadata.cs b/src/KubernetesClient.Models/IMetadata.cs deleted file mode 100644 index e633e9e85..000000000 --- a/src/KubernetesClient.Models/IMetadata.cs +++ /dev/null @@ -1,18 +0,0 @@ -using k8s.Models; - -namespace k8s -{ - /// - /// Kubernetes object that exposes metadata - /// - /// Type of metadata exposed. Usually this will be either - /// for lists or for objects - public interface IMetadata - { - /// - /// Gets or sets standard object's metadata. More info: - /// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata - /// - T Metadata { get; set; } - } -} diff --git a/src/KubernetesClient.Models/ISpec.cs b/src/KubernetesClient.Models/ISpec.cs deleted file mode 100644 index d286b7cca..000000000 --- a/src/KubernetesClient.Models/ISpec.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace k8s -{ - /// - /// Represents a Kubernetes object that has a spec - /// - /// type of Kubernetes object - public interface ISpec - { - /// - /// Gets or sets specification of the desired behavior of the entity. More - /// info: - /// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - /// - T Spec { get; set; } - } -} diff --git a/src/KubernetesClient.Models/IValidate.cs b/src/KubernetesClient.Models/IValidate.cs deleted file mode 100644 index c81f553f2..000000000 --- a/src/KubernetesClient.Models/IValidate.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace k8s -{ - /// - /// Object that allows self validation - /// - public interface IValidate - { - /// - /// Validate the object. - /// - void Validate(); - } -} diff --git a/src/KubernetesClient.Models/IntstrIntOrString.cs b/src/KubernetesClient.Models/IntstrIntOrString.cs deleted file mode 100644 index 6f378df9b..000000000 --- a/src/KubernetesClient.Models/IntstrIntOrString.cs +++ /dev/null @@ -1,56 +0,0 @@ -namespace k8s.Models -{ - [JsonConverter(typeof(IntOrStringJsonConverter))] - public partial class IntstrIntOrString - { - public static implicit operator IntstrIntOrString(int v) - { - return new IntstrIntOrString(Convert.ToString(v)); - } - - public static implicit operator IntstrIntOrString(long v) - { - return new IntstrIntOrString(Convert.ToString(v)); - } - - public static implicit operator string(IntstrIntOrString v) - { - return v?.Value; - } - - public static implicit operator IntstrIntOrString(string v) - { - return new IntstrIntOrString(v); - } - - protected bool Equals(IntstrIntOrString other) - { - return string.Equals(Value, other?.Value); - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - if (obj.GetType() != GetType()) - { - return false; - } - - return Equals((IntstrIntOrString)obj); - } - - public override int GetHashCode() - { - return Value != null ? Value.GetHashCode() : 0; - } - } -} diff --git a/src/KubernetesClient.Models/KubernetesClient.Models.csproj b/src/KubernetesClient.Models/KubernetesClient.Models.csproj deleted file mode 100644 index d3a7fbe10..000000000 --- a/src/KubernetesClient.Models/KubernetesClient.Models.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - netstandard2.0 - k8s.Models - - - - - - - - - - - - - - - diff --git a/src/KubernetesClient.Models/KubernetesJson.cs b/src/KubernetesClient.Models/KubernetesJson.cs deleted file mode 100644 index ff22037e6..000000000 --- a/src/KubernetesClient.Models/KubernetesJson.cs +++ /dev/null @@ -1,85 +0,0 @@ -using k8s.Models; -using System.Globalization; -using System.IO; -using System.Xml; - -namespace k8s -{ - public static class KubernetesJson - { - private static readonly JsonSerializerOptions JsonSerializerOptions = new JsonSerializerOptions(); - - private sealed class Iso8601TimeSpanConverter : JsonConverter - { - public override TimeSpan Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - var str = reader.GetString(); - return XmlConvert.ToTimeSpan(str); - } - - public override void Write(Utf8JsonWriter writer, TimeSpan value, JsonSerializerOptions options) - { - var iso8601TimeSpanString = XmlConvert.ToString(value); // XmlConvert for TimeSpan uses ISO8601, so delegate serialization to it - writer.WriteStringValue(iso8601TimeSpanString); - } - } - - private sealed class KubernetesDateTimeOffsetConverter : JsonConverter - { - private const string SerializeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.ffffffK"; - private const string Iso8601Format = "yyyy'-'MM'-'dd'T'HH':'mm':'ssK"; - - public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - var str = reader.GetString(); - return DateTimeOffset.ParseExact(str, new[] { Iso8601Format, SerializeFormat }, CultureInfo.InvariantCulture, DateTimeStyles.None); - } - - public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options) - { - writer.WriteStringValue(value.ToString(SerializeFormat)); - } - } - - private sealed class KubernetesDateTimeConverter : JsonConverter - { - private static readonly JsonConverter UtcConverter = new KubernetesDateTimeOffsetConverter(); - public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - return UtcConverter.Read(ref reader, typeToConvert, options).UtcDateTime; - } - - public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options) - { - UtcConverter.Write(writer, value, options); - } - } - - static KubernetesJson() - { - JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; - JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; - JsonSerializerOptions.Converters.Add(new Iso8601TimeSpanConverter()); - JsonSerializerOptions.Converters.Add(new KubernetesDateTimeConverter()); - JsonSerializerOptions.Converters.Add(new KubernetesDateTimeOffsetConverter()); - JsonSerializerOptions.Converters.Add(new V1Status.V1StatusObjectViewConverter()); - JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); - } - - public static TValue Deserialize(string json) - { - return JsonSerializer.Deserialize(json, JsonSerializerOptions); - } - - public static TValue Deserialize(Stream json) - { - return JsonSerializer.Deserialize(json, JsonSerializerOptions); - } - - - public static string Serialize(object value) - { - return JsonSerializer.Serialize(value, JsonSerializerOptions); - } - } -} diff --git a/src/KubernetesClient.Models/ResourceQuantityJsonConverter.cs b/src/KubernetesClient.Models/ResourceQuantityJsonConverter.cs deleted file mode 100644 index 3d64f48f1..000000000 --- a/src/KubernetesClient.Models/ResourceQuantityJsonConverter.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace k8s.Models -{ - internal sealed class ResourceQuantityJsonConverter : JsonConverter - { - public override ResourceQuantity Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - return new ResourceQuantity(reader.GetString()); - } - - public override void Write(Utf8JsonWriter writer, ResourceQuantity value, JsonSerializerOptions options) - { - if (writer == null) - { - throw new ArgumentNullException(nameof(writer)); - } - - writer.WriteStringValue(value?.ToString()); - } - } -} diff --git a/src/KubernetesClient.Models/Versioning/KubernetesVersionComparer.cs b/src/KubernetesClient.Models/Versioning/KubernetesVersionComparer.cs deleted file mode 100644 index bd2435920..000000000 --- a/src/KubernetesClient.Models/Versioning/KubernetesVersionComparer.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Text.RegularExpressions; - -namespace k8s.Versioning -{ - public class KubernetesVersionComparer : IComparer - { - public static KubernetesVersionComparer Instance { get; } = new KubernetesVersionComparer(); - private static readonly Regex KubernetesVersionRegex = new Regex(@"^v(?[0-9]+)((?alpha|beta)(?[0-9]+))?$", RegexOptions.Compiled); - - internal KubernetesVersionComparer() - { - } - - public int Compare(string x, string y) - { - if (x == null || y == null) - { - return StringComparer.CurrentCulture.Compare(x, y); - } - - var matchX = KubernetesVersionRegex.Match(x); - if (!matchX.Success) - { - return StringComparer.CurrentCulture.Compare(x, y); - } - - var matchY = KubernetesVersionRegex.Match(y); - if (!matchY.Success) - { - return StringComparer.CurrentCulture.Compare(x, y); - } - - var versionX = ExtractVersion(matchX); - var versionY = ExtractVersion(matchY); - return versionX.CompareTo(versionY); - } - - private Version ExtractVersion(Match match) - { - var major = int.Parse(match.Groups["major"].Value); - if (!Enum.TryParse(match.Groups["stream"].Value, true, out var stream)) - { - stream = Stream.Final; - } - - _ = int.TryParse(match.Groups["minor"].Value, out var minor); - return new Version(major, (int)stream, minor); - } - - private enum Stream - { - Alpha = 1, - Beta = 2, - Final = 3, - } - } -} diff --git a/src/KubernetesClient.Models/Versioning/VersionConverter.cs b/src/KubernetesClient.Models/Versioning/VersionConverter.cs deleted file mode 100644 index 914b111b7..000000000 --- a/src/KubernetesClient.Models/Versioning/VersionConverter.cs +++ /dev/null @@ -1,165 +0,0 @@ -// WARNING: DO NOT LEAVE COMMENTED CODE IN THIS FILE. IT GETS SCANNED BY GEN PROJECT SO IT CAN EXCLUDE ANY MANUALLY DEFINED MAPS - -using System.Reflection; -using AutoMapper; -using k8s.Models; - -namespace k8s.Versioning -{ - /// - /// Provides mappers that converts Kubernetes models between different versions - /// - public static partial class VersionConverter - { - static VersionConverter() - { - UpdateMappingConfiguration(expression => { }); - } - - public static IMapper Mapper { get; private set; } - internal static MapperConfiguration MapperConfiguration { get; private set; } - - /// - /// Two level lookup of model types by Kind and then Version - /// - internal static Dictionary> KindVersionsMap { get; private set; } - - public static Type GetTypeForVersion(string version) - { - return GetTypeForVersion(typeof(T), version); - } - - public static Type GetTypeForVersion(Type type, string version) - { - return KindVersionsMap[type.GetKubernetesTypeMetadata().Kind][version]; - } - - public static void UpdateMappingConfiguration(Action configuration) - { - MapperConfiguration = new MapperConfiguration(cfg => - { - GetConfigurations(cfg); - configuration(cfg); - }); - Mapper = MapperConfiguration.CreateMapper(); - KindVersionsMap = MapperConfiguration - .GetAllTypeMaps() - .SelectMany(x => new[] { x.Types.SourceType, x.Types.DestinationType }) - .Where(x => x.GetCustomAttribute() != null) - .Select(x => - { - var attr = GetKubernetesEntityAttribute(x); - return new { attr.Kind, attr.ApiVersion, Type = x }; - }) - .GroupBy(x => x.Kind) - .ToDictionary(x => x.Key, kindGroup => kindGroup - .GroupBy(x => x.ApiVersion) - .ToDictionary( - x => x.Key, - versionGroup => versionGroup.Select(x => x.Type).Distinct().Single())); // should only be one type for each Kind/Version combination - } - - public static object ConvertToVersion(object source, string apiVersion) - { - if (source == null) - { - throw new ArgumentNullException(nameof(source)); - } - - var type = source.GetType(); - var attr = GetKubernetesEntityAttribute(type); - if (attr.ApiVersion == apiVersion) - { - return source; - } - - if (!KindVersionsMap.TryGetValue(attr.Kind, out var kindVersions)) - { - throw new InvalidOperationException($"Version converter does not have any registered types for Kind `{attr.Kind}`"); - } - - if (!kindVersions.TryGetValue(apiVersion, out var targetType) || !kindVersions.TryGetValue(attr.ApiVersion, out var sourceType) || MapperConfiguration.FindTypeMapFor(sourceType, targetType) == null) - { - throw new InvalidOperationException($"There is no conversion mapping registered for Kind `{attr.Kind}` from ApiVersion {attr.ApiVersion} to {apiVersion}"); - } - - return Mapper.Map(source, sourceType, targetType); - } - - private static KubernetesEntityAttribute GetKubernetesEntityAttribute(Type type) - { - if (type == null) - { - throw new ArgumentNullException(nameof(type)); - } - - var attr = type.GetCustomAttribute(); - if (attr == null) - { - throw new InvalidOperationException($"Type {type} does not have {nameof(KubernetesEntityAttribute)}"); - } - - return attr; - } - - internal static void GetConfigurations(IMapperConfigurationExpression cfg) - { - AutoConfigurations(cfg); - ManualConfigurations(cfg); - } - - private static void ManualConfigurations(IMapperConfigurationExpression cfg) - { - cfg.AllowNullCollections = true; - cfg.DisableConstructorMapping(); - cfg.ForAllMaps((typeMap, opt) => - { - if (!typeof(IKubernetesObject).IsAssignableFrom(typeMap.Types.DestinationType)) - { - return; - } - - var metadata = typeMap.Types.DestinationType.GetKubernetesTypeMetadata(); - opt.ForMember(nameof(IKubernetesObject.ApiVersion), x => x.Ignore()); - opt.ForMember(nameof(IKubernetesObject.Kind), x => x.Ignore()); - opt.AfterMap((from, to) => - { - var obj = (IKubernetesObject)to; - obj.ApiVersion = !string.IsNullOrEmpty(metadata.Group) ? $"{metadata.Group}/{metadata.ApiVersion}" : metadata.ApiVersion; - obj.Kind = metadata.Kind; - }); - }); - cfg.CreateMap() - .ForMember(dest => dest.Group, opt => opt.Ignore()) - .ForMember(dest => dest.ServiceAccount, opt => opt.Ignore()) - .ForMember(dest => dest.User, opt => opt.Ignore()) - .ReverseMap(); - cfg.CreateMap() - .ForMember(dest => dest.Group, opt => opt.Ignore()) - .ForMember(dest => dest.ServiceAccount, opt => opt.Ignore()) - .ForMember(dest => dest.User, opt => opt.Ignore()) - .ReverseMap(); - - - cfg.CreateMap() - .ForMember(dest => dest.Metrics, opt => opt.Ignore()) - .ForMember(dest => dest.Behavior, opt => opt.Ignore()) - .ReverseMap(); - - cfg.CreateMap() - .ForMember(dest => dest.Metrics, opt => opt.Ignore()) - .ForMember(dest => dest.Behavior, opt => opt.Ignore()) - .ReverseMap(); - - - cfg.CreateMap() - .ForMember(dest => dest.Conditions, opt => opt.Ignore()) - .ForMember(dest => dest.CurrentMetrics, opt => opt.Ignore()) - .ReverseMap(); - cfg.CreateMap() - .ForMember(dest => dest.Conditions, opt => opt.Ignore()) - .ForMember(dest => dest.CurrentMetrics, opt => opt.Ignore()) - .ReverseMap(); - } - } -} diff --git a/src/KubernetesClient.Util/KubernetesClient.Util.csproj b/src/KubernetesClient.Util/KubernetesClient.Util.csproj deleted file mode 100644 index febeee354..000000000 --- a/src/KubernetesClient.Util/KubernetesClient.Util.csproj +++ /dev/null @@ -1,42 +0,0 @@ - - - - 9.0 - The Kubernetes Project Authors - 2017 The Kubernetes Project Authors - Supprting utilities for the kubernetes open source container orchestrator client library. - - Apache-2.0 - https://github.com/kubernetes-client/csharp - https://raw.githubusercontent.com/kubernetes/kubernetes/master/logo/logo.png - kubernetes;docker;containers; - - netstandard2.1;net5.0 - k8s.Util - true - true - - - true - - - true - snupkg - true - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - - - - - - - - - - - - - - - - diff --git a/src/KubernetesClient.Basic/AbstractKubernetes.cs b/src/KubernetesClient/AbstractKubernetes.cs similarity index 77% rename from src/KubernetesClient.Basic/AbstractKubernetes.cs rename to src/KubernetesClient/AbstractKubernetes.cs index dd774611d..1d6ed2ae7 100644 --- a/src/KubernetesClient.Basic/AbstractKubernetes.cs +++ b/src/KubernetesClient/AbstractKubernetes.cs @@ -14,12 +14,18 @@ private static class HttpMethods public static readonly HttpMethod Post = HttpMethod.Post; public static readonly HttpMethod Put = HttpMethod.Put; public static readonly HttpMethod Trace = HttpMethod.Trace; + +#if NETSTANDARD2_0 || NET48 public static readonly HttpMethod Patch = new HttpMethod("PATCH"); +#else + public static readonly HttpMethod Patch = HttpMethod.Patch; +#endif + } private sealed class QueryBuilder { - private List parameters = new List(); + private readonly List parameters = new List(); public void Append(string key, params object[] values) { @@ -54,19 +60,6 @@ public override string ToString() } } - private Task SendRequest(T body, HttpRequestMessage httpRequest, CancellationToken cancellationToken) - { - if (body != null) - { - var requestContent = KubernetesJson.Serialize(body); - httpRequest.Content = new StringContent(requestContent, System.Text.Encoding.UTF8); - httpRequest.Content.Headers.ContentType = GetHeader(body); - return SendRequestRaw(requestContent, httpRequest, cancellationToken); - } - - return SendRequestRaw("", httpRequest, cancellationToken); - } - public virtual TimeSpan HttpClientTimeout { get; set; } = TimeSpan.FromSeconds(100); protected virtual MediaTypeHeaderValue GetHeader(object body) @@ -108,7 +101,5 @@ private MediaTypeHeaderValue GetHeader(V1Patch body) protected abstract Task> CreateResultAsync(HttpRequestMessage httpRequest, HttpResponseMessage httpResponse, bool? watch, CancellationToken cancellationToken); - protected abstract HttpRequestMessage CreateRequest(string relativeUri, HttpMethod method, IReadOnlyDictionary> customHeaders); - - protected abstract Task SendRequestRaw(string requestContent, HttpRequestMessage httpRequest, CancellationToken cancellationToken); + protected abstract Task SendRequest(string relativeUri, HttpMethod method, IReadOnlyDictionary> customHeaders, T body, CancellationToken cancellationToken); } diff --git a/src/KubernetesClient/AssemblyInfo.cs b/src/KubernetesClient/AssemblyInfo.cs deleted file mode 100644 index a70d9e832..000000000 --- a/src/KubernetesClient/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("KubernetesClient.Tests")] diff --git a/src/KubernetesClient.Basic/Autorest/BasicAuthenticationCredentials.cs b/src/KubernetesClient/Authentication/BasicAuthenticationCredentials.cs similarity index 98% rename from src/KubernetesClient.Basic/Autorest/BasicAuthenticationCredentials.cs rename to src/KubernetesClient/Authentication/BasicAuthenticationCredentials.cs index 46975b5da..0f0964544 100644 --- a/src/KubernetesClient.Basic/Autorest/BasicAuthenticationCredentials.cs +++ b/src/KubernetesClient/Authentication/BasicAuthenticationCredentials.cs @@ -6,7 +6,7 @@ using System.Net.Http.Headers; using System.Text; -namespace k8s.Autorest +namespace k8s.Authentication { /// /// Basic Auth credentials for use with a REST Service Client. diff --git a/src/KubernetesClient/Authentication/ExecTokenProvider.cs b/src/KubernetesClient/Authentication/ExecTokenProvider.cs index d445b9109..26bc9b961 100644 --- a/src/KubernetesClient/Authentication/ExecTokenProvider.cs +++ b/src/KubernetesClient/Authentication/ExecTokenProvider.cs @@ -1,8 +1,5 @@ -using System.Net.Http.Headers; -using System.Threading; -using System.Threading.Tasks; using k8s.KubeConfigModels; -using k8s.Autorest; +using System.Net.Http.Headers; namespace k8s.Authentication { diff --git a/src/KubernetesClient/Authentication/GcpTokenProvider.cs b/src/KubernetesClient/Authentication/GcpTokenProvider.cs deleted file mode 100644 index de6671da6..000000000 --- a/src/KubernetesClient/Authentication/GcpTokenProvider.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System.Diagnostics; -using System.Net.Http.Headers; -using System.Threading; -using System.Threading.Tasks; -using k8s.Exceptions; -using k8s.Autorest; - -namespace k8s.Authentication -{ - public class GcpTokenProvider : ITokenProvider - { - private readonly string _gcloudCli; - private string _token; - private DateTime _expiry; - - public GcpTokenProvider(string gcloudCli) - { - _gcloudCli = gcloudCli; - } - - public async Task GetAuthenticationHeaderAsync(CancellationToken cancellationToken) - { - if (DateTime.UtcNow.AddSeconds(30) > _expiry) - { - await RefreshToken().ConfigureAwait(false); - } - - return new AuthenticationHeaderValue("Bearer", _token); - } - - private async Task RefreshToken() - { - var process = new Process - { - StartInfo = - { - FileName = _gcloudCli, - Arguments = "config config-helper --format=json", - UseShellExecute = false, - CreateNoWindow = true, - RedirectStandardOutput = true, - RedirectStandardError = true, - }, - EnableRaisingEvents = true, - }; - var tcs = new TaskCompletionSource(); - process.Exited += (sender, arg) => - { - tcs.SetResult(true); - }; - process.Start(); - var output = process.StandardOutput.ReadToEndAsync(); - var err = process.StandardError.ReadToEndAsync(); - - await Task.WhenAll(tcs.Task, output, err).ConfigureAwait(false); - - if (process.ExitCode != 0) - { - throw new KubernetesClientException($"Unable to obtain a token via gcloud command. Error code {process.ExitCode}. \n {err}"); - } - - dynamic json = JsonSerializer.Deserialize(await output.ConfigureAwait(false), new - { - credential = new - { - access_token = "", - token_expiry = DateTime.UtcNow, - }, - }.GetType()); - - _token = json.credential.access_token; - _expiry = json.credential.token_expiry; - } - } -} diff --git a/src/KubernetesClient.Basic/Autorest/ITokenProvider.cs b/src/KubernetesClient/Authentication/ITokenProvider.cs similarity index 96% rename from src/KubernetesClient.Basic/Autorest/ITokenProvider.cs rename to src/KubernetesClient/Authentication/ITokenProvider.cs index 9414960e0..a04f7600b 100644 --- a/src/KubernetesClient.Basic/Autorest/ITokenProvider.cs +++ b/src/KubernetesClient/Authentication/ITokenProvider.cs @@ -5,7 +5,7 @@ #pragma warning disable SA1606 #pragma warning disable SA1614 -namespace k8s.Autorest +namespace k8s.Authentication { /// /// Interface to a source of access tokens. diff --git a/src/KubernetesClient/Authentication/OidcTokenProvider.cs b/src/KubernetesClient/Authentication/OidcTokenProvider.cs index 51a6a22e5..912ea0fde 100644 --- a/src/KubernetesClient/Authentication/OidcTokenProvider.cs +++ b/src/KubernetesClient/Authentication/OidcTokenProvider.cs @@ -1,26 +1,28 @@ -using IdentityModel.OidcClient; using k8s.Exceptions; -using k8s.Autorest; -using System.IdentityModel.Tokens.Jwt; +using System.Net.Http; using System.Net.Http.Headers; -using System.Threading; -using System.Threading.Tasks; +using System.Text; namespace k8s.Authentication { public class OidcTokenProvider : ITokenProvider { - private OidcClient _oidcClient; + private readonly string _clientId; + private readonly string _clientSecret; + private readonly string _idpIssuerUrl; + private string _idToken; private string _refreshToken; private DateTimeOffset _expiry; public OidcTokenProvider(string clientId, string clientSecret, string idpIssuerUrl, string idToken, string refreshToken) { + _clientId = clientId; + _clientSecret = clientSecret; + _idpIssuerUrl = idpIssuerUrl; _idToken = idToken; _refreshToken = refreshToken; - _oidcClient = getClient(clientId, clientSecret, idpIssuerUrl); - _expiry = getExpiryFromToken(); + _expiry = GetExpiryFromToken(); } public async Task GetAuthenticationHeaderAsync(CancellationToken cancellationToken) @@ -33,49 +35,77 @@ public async Task GetAuthenticationHeaderAsync(Cancel return new AuthenticationHeaderValue("Bearer", _idToken); } - private DateTime getExpiryFromToken() + private DateTimeOffset GetExpiryFromToken() { - int expiry; - var handler = new JwtSecurityTokenHandler(); try { - var token = handler.ReadJwtToken(_idToken); - expiry = token.Payload.Exp ?? 0; + var parts = _idToken.Split('.'); + var payload = parts[1]; + var jsonBytes = Base64UrlDecode(payload); + var json = Encoding.UTF8.GetString(jsonBytes); + + using var document = JsonDocument.Parse(json); + if (document.RootElement.TryGetProperty("exp", out var expElement)) + { + var exp = expElement.GetInt64(); + return DateTimeOffset.FromUnixTimeSeconds(exp); + } } catch { - expiry = 0; + // ignore to default } - return DateTimeOffset.FromUnixTimeSeconds(expiry).UtcDateTime; + return default; } - private OidcClient getClient(string clientId, string clientSecret, string idpIssuerUrl) + private static byte[] Base64UrlDecode(string input) { - OidcClientOptions options = new OidcClientOptions + var output = input.Replace('-', '+').Replace('_', '/'); + switch (output.Length % 4) { - ClientId = clientId, - ClientSecret = clientSecret ?? "", - Authority = idpIssuerUrl, - }; + case 2: output += "=="; break; + case 3: output += "="; break; + } - return new OidcClient(options); + return Convert.FromBase64String(output); } private async Task RefreshToken() { try { - var result = await _oidcClient.RefreshTokenAsync(_refreshToken).ConfigureAwait(false); + using var httpClient = new HttpClient(); + var request = new HttpRequestMessage(HttpMethod.Post, _idpIssuerUrl); + request.Content = new FormUrlEncodedContent(new Dictionary + { + { "grant_type", "refresh_token" }, + { "client_id", _clientId }, + { "client_secret", _clientSecret }, + { "refresh_token", _refreshToken }, + }); + + var response = await httpClient.SendAsync(request).ConfigureAwait(false); + response.EnsureSuccessStatusCode(); - if (result.IsError) + var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + var jsonDocument = JsonDocument.Parse(responseContent); + + if (jsonDocument.RootElement.TryGetProperty("id_token", out var idTokenElement)) + { + _idToken = idTokenElement.GetString(); + } + + if (jsonDocument.RootElement.TryGetProperty("refresh_token", out var refreshTokenElement)) { - throw new Exception(result.Error); + _refreshToken = refreshTokenElement.GetString(); } - _idToken = result.IdentityToken; - _refreshToken = result.RefreshToken; - _expiry = result.AccessTokenExpiration; + if (jsonDocument.RootElement.TryGetProperty("expires_in", out var expiresInElement)) + { + var expiresIn = expiresInElement.GetInt32(); + _expiry = DateTimeOffset.UtcNow.AddSeconds(expiresIn); + } } catch (Exception e) { diff --git a/src/KubernetesClient.Basic/Autorest/ServiceClientCredentials.cs b/src/KubernetesClient/Authentication/ServiceClientCredentials.cs similarity index 97% rename from src/KubernetesClient.Basic/Autorest/ServiceClientCredentials.cs rename to src/KubernetesClient/Authentication/ServiceClientCredentials.cs index d001d005b..d8ec8bb67 100644 --- a/src/KubernetesClient.Basic/Autorest/ServiceClientCredentials.cs +++ b/src/KubernetesClient/Authentication/ServiceClientCredentials.cs @@ -3,7 +3,7 @@ using System.Net.Http; -namespace k8s.Autorest +namespace k8s.Authentication { /// /// ServiceClientCredentials is the abstraction for credentials used by ServiceClients accessing REST services. diff --git a/src/KubernetesClient.Basic/Autorest/StringTokenProvider.cs b/src/KubernetesClient/Authentication/StringTokenProvider.cs similarity index 98% rename from src/KubernetesClient.Basic/Autorest/StringTokenProvider.cs rename to src/KubernetesClient/Authentication/StringTokenProvider.cs index c4c6403c6..680dd2f9b 100644 --- a/src/KubernetesClient.Basic/Autorest/StringTokenProvider.cs +++ b/src/KubernetesClient/Authentication/StringTokenProvider.cs @@ -3,7 +3,7 @@ using System.Net.Http.Headers; -namespace k8s.Autorest +namespace k8s.Authentication { /// /// A simple token provider that always provides a static access token. diff --git a/src/KubernetesClient.Basic/Autorest/TokenCredentials.cs b/src/KubernetesClient/Authentication/TokenCredentials.cs similarity index 95% rename from src/KubernetesClient.Basic/Autorest/TokenCredentials.cs rename to src/KubernetesClient/Authentication/TokenCredentials.cs index f48c5436f..ed272627e 100644 --- a/src/KubernetesClient.Basic/Autorest/TokenCredentials.cs +++ b/src/KubernetesClient/Authentication/TokenCredentials.cs @@ -3,7 +3,7 @@ using System.Net.Http; -namespace k8s.Autorest +namespace k8s.Authentication { /// /// Token based credentials for use with a REST Service Client. @@ -73,7 +73,7 @@ public TokenCredentials(ITokenProvider tokenProvider) throw new ArgumentNullException("tokenProvider"); } - this.TokenProvider = tokenProvider; + TokenProvider = tokenProvider; } /// @@ -86,8 +86,8 @@ public TokenCredentials(ITokenProvider tokenProvider) public TokenCredentials(ITokenProvider tokenProvider, string tenantId, string callerId) : this(tokenProvider) { - this.TenantId = tenantId; - this.CallerId = callerId; + TenantId = tenantId; + CallerId = callerId; } /// @@ -98,7 +98,7 @@ public TokenCredentials(ITokenProvider tokenProvider, string tenantId, string ca /// /// Task that will complete when processing has completed. /// - public async override Task ProcessHttpRequestAsync( + public override async Task ProcessHttpRequestAsync( HttpRequestMessage request, CancellationToken cancellationToken) { diff --git a/src/KubernetesClient/Authentication/TokenFileAuth.cs b/src/KubernetesClient/Authentication/TokenFileAuth.cs index 84f7ae2cb..5d423aeb4 100644 --- a/src/KubernetesClient/Authentication/TokenFileAuth.cs +++ b/src/KubernetesClient/Authentication/TokenFileAuth.cs @@ -1,8 +1,4 @@ using System.Net.Http.Headers; -using System.IO; -using System.Threading; -using System.Threading.Tasks; -using k8s.Autorest; namespace k8s.Authentication { diff --git a/src/KubernetesClient.Basic/Autorest/HttpExtensions.cs b/src/KubernetesClient/Autorest/HttpExtensions.cs similarity index 100% rename from src/KubernetesClient.Basic/Autorest/HttpExtensions.cs rename to src/KubernetesClient/Autorest/HttpExtensions.cs diff --git a/src/KubernetesClient.Basic/Autorest/HttpMessageWrapper.cs b/src/KubernetesClient/Autorest/HttpMessageWrapper.cs similarity index 100% rename from src/KubernetesClient.Basic/Autorest/HttpMessageWrapper.cs rename to src/KubernetesClient/Autorest/HttpMessageWrapper.cs diff --git a/src/KubernetesClient.Basic/Autorest/HttpOperationException.cs b/src/KubernetesClient/Autorest/HttpOperationException.cs similarity index 76% rename from src/KubernetesClient.Basic/Autorest/HttpOperationException.cs rename to src/KubernetesClient/Autorest/HttpOperationException.cs index f698ef1b2..e5da86864 100644 --- a/src/KubernetesClient.Basic/Autorest/HttpOperationException.cs +++ b/src/KubernetesClient/Autorest/HttpOperationException.cs @@ -1,15 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -using System.Runtime.Serialization; - namespace k8s.Autorest { /// /// Exception thrown for an invalid response with custom error information. /// - [Serializable] - public class HttpOperationException : RestException + public class HttpOperationException : Exception { /// /// Gets information about the associated HTTP request. @@ -51,15 +48,5 @@ public HttpOperationException(string message, Exception innerException) : base(message, innerException) { } - - /// - /// Initializes a new instance of the class. - /// - /// Serialization info. - /// Streaming context. - protected HttpOperationException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } diff --git a/src/KubernetesClient.Basic/Autorest/HttpOperationResponse.cs b/src/KubernetesClient/Autorest/HttpOperationResponse.cs similarity index 100% rename from src/KubernetesClient.Basic/Autorest/HttpOperationResponse.cs rename to src/KubernetesClient/Autorest/HttpOperationResponse.cs diff --git a/src/KubernetesClient.Basic/Autorest/HttpRequestMessageWrapper.cs b/src/KubernetesClient/Autorest/HttpRequestMessageWrapper.cs similarity index 61% rename from src/KubernetesClient.Basic/Autorest/HttpRequestMessageWrapper.cs rename to src/KubernetesClient/Autorest/HttpRequestMessageWrapper.cs index efdefa0ef..067429e24 100644 --- a/src/KubernetesClient.Basic/Autorest/HttpRequestMessageWrapper.cs +++ b/src/KubernetesClient/Autorest/HttpRequestMessageWrapper.cs @@ -24,22 +24,12 @@ public HttpRequestMessageWrapper(HttpRequestMessage httpRequest, string content) throw new ArgumentNullException("httpRequest"); } - this.CopyHeaders(httpRequest.Headers); - this.CopyHeaders(httpRequest.GetContentHeaders()); + CopyHeaders(httpRequest.Headers); + CopyHeaders(httpRequest.GetContentHeaders()); - this.Content = content; - this.Method = httpRequest.Method; - this.RequestUri = httpRequest.RequestUri; -#pragma warning disable CS0618 // Type or member is obsolete - if (httpRequest.Properties != null) - { - Properties = new Dictionary(); - foreach (KeyValuePair pair in httpRequest.Properties) -#pragma warning restore CS0618 // Type or member is obsolete - { - this.Properties[pair.Key] = pair.Value; - } - } + Content = content; + Method = httpRequest.Method; + RequestUri = httpRequest.RequestUri; } /// @@ -51,10 +41,5 @@ public HttpRequestMessageWrapper(HttpRequestMessage httpRequest, string content) /// Gets or sets the Uri used for the HTTP request. /// public Uri RequestUri { get; protected set; } - - /// - /// Gets a set of properties for the HTTP request. - /// - public IDictionary Properties { get; private set; } } } diff --git a/src/KubernetesClient.Basic/Autorest/HttpResponseMessageWrapper.cs b/src/KubernetesClient/Autorest/HttpResponseMessageWrapper.cs similarity index 84% rename from src/KubernetesClient.Basic/Autorest/HttpResponseMessageWrapper.cs rename to src/KubernetesClient/Autorest/HttpResponseMessageWrapper.cs index d12424406..aaa822fa4 100644 --- a/src/KubernetesClient.Basic/Autorest/HttpResponseMessageWrapper.cs +++ b/src/KubernetesClient/Autorest/HttpResponseMessageWrapper.cs @@ -25,12 +25,12 @@ public HttpResponseMessageWrapper(HttpResponseMessage httpResponse, string conte throw new ArgumentNullException("httpResponse"); } - this.CopyHeaders(httpResponse.Headers); - this.CopyHeaders(httpResponse.GetContentHeaders()); + CopyHeaders(httpResponse.Headers); + CopyHeaders(httpResponse.GetContentHeaders()); - this.Content = content; - this.StatusCode = httpResponse.StatusCode; - this.ReasonPhrase = httpResponse.ReasonPhrase; + Content = content; + StatusCode = httpResponse.StatusCode; + ReasonPhrase = httpResponse.ReasonPhrase; } /// diff --git a/src/KubernetesClient/ByteBuffer.cs b/src/KubernetesClient/ByteBuffer.cs index eb0d1366b..a6bc92fa0 100644 --- a/src/KubernetesClient/ByteBuffer.cs +++ b/src/KubernetesClient/ByteBuffer.cs @@ -1,6 +1,5 @@ using System.Buffers; using System.Diagnostics; -using System.Threading; namespace k8s { diff --git a/src/KubernetesClient/CertUtils.cs b/src/KubernetesClient/CertUtils.cs index d1881c87c..7a398d7e8 100644 --- a/src/KubernetesClient/CertUtils.cs +++ b/src/KubernetesClient/CertUtils.cs @@ -1,16 +1,7 @@ using k8s.Exceptions; -#if !NET5_0_OR_GREATER -using Org.BouncyCastle.Crypto; -using Org.BouncyCastle.OpenSsl; -using Org.BouncyCastle.Pkcs; -using Org.BouncyCastle.Security; -using Org.BouncyCastle.X509; -#else using System.Runtime.InteropServices; -using System.Text; -#endif -using System.IO; using System.Security.Cryptography.X509Certificates; +using System.Text; namespace k8s { @@ -24,21 +15,9 @@ internal static class CertUtils public static X509Certificate2Collection LoadPemFileCert(string file) { var certCollection = new X509Certificate2Collection(); - using (var stream = FileUtils.FileSystem().File.OpenRead(file)) + using (var stream = FileSystem.Current.OpenRead(file)) { -#if NET5_0_OR_GREATER certCollection.ImportFromPem(new StreamReader(stream).ReadToEnd()); -#else - var certs = new X509CertificateParser().ReadCertificates(stream); - - // Convert BouncyCastle X509Certificates to the .NET cryptography implementation and add - // it to the certificate collection - // - foreach (Org.BouncyCastle.X509.X509Certificate cert in certs) - { - certCollection.Add(new X509Certificate2(cert.GetEncoded())); - } -#endif } return certCollection; @@ -56,7 +35,6 @@ public static X509Certificate2 GeneratePfx(KubernetesClientConfiguration config) throw new ArgumentNullException(nameof(config)); } -#if NET5_0_OR_GREATER string keyData = null; string certData = null; @@ -96,86 +74,30 @@ public static X509Certificate2 GeneratePfx(KubernetesClientConfiguration config) // see https://github.com/kubernetes-client/csharp/issues/737 if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - cert = new X509Certificate2(cert.Export(X509ContentType.Pkcs12)); - } - - return cert; -#else - - byte[] keyData = null; - byte[] certData = null; - - if (!string.IsNullOrWhiteSpace(config.ClientCertificateKeyData)) - { - keyData = Convert.FromBase64String(config.ClientCertificateKeyData); - } - - if (!string.IsNullOrWhiteSpace(config.ClientKeyFilePath)) - { - keyData = File.ReadAllBytes(config.ClientKeyFilePath); - } - - if (keyData == null) - { - throw new KubeConfigException("keyData is empty"); - } - - if (!string.IsNullOrWhiteSpace(config.ClientCertificateData)) - { - certData = Convert.FromBase64String(config.ClientCertificateData); - } - - if (!string.IsNullOrWhiteSpace(config.ClientCertificateFilePath)) - { - certData = File.ReadAllBytes(config.ClientCertificateFilePath); - } - - if (certData == null) - { - throw new KubeConfigException("certData is empty"); - } - - var cert = new X509CertificateParser().ReadCertificate(new MemoryStream(certData)); - // key usage is a bit string, zero-th bit is 'digitalSignature' - // See https://www.alvestrand.no/objectid/2.5.29.15.html for more details. - if (cert != null && cert.GetKeyUsage() != null && !cert.GetKeyUsage()[0]) - { - throw new Exception( - "Client certificates must be marked for digital signing. " + - "See https://github.com/kubernetes-client/csharp/issues/319"); - } - - object obj; - using (var reader = new StreamReader(new MemoryStream(keyData))) - { - obj = new PemReader(reader).ReadObject(); - var key = obj as AsymmetricCipherKeyPair; - if (key != null) - { - var cipherKey = key; - obj = cipherKey.Private; - } - } - - var keyParams = (AsymmetricKeyParameter)obj; - - var store = new Pkcs12StoreBuilder().Build(); - store.SetKeyEntry("K8SKEY", new AsymmetricKeyEntry(keyParams), new[] { new X509CertificateEntry(cert) }); - - using (var pkcs = new MemoryStream()) - { - store.Save(pkcs, new char[0], new SecureRandom()); + // This null password is to change the constructor to fix this KB: + // https://support.microsoft.com/en-us/topic/kb5025823-change-in-how-net-applications-import-x-509-certificates-bf81c936-af2b-446e-9f7a-016f4713b46b + string nullPassword = null; if (config.ClientCertificateKeyStoreFlags.HasValue) { - return new X509Certificate2(pkcs.ToArray(), "", config.ClientCertificateKeyStoreFlags.Value); +#if NET9_0_OR_GREATER + cert = X509CertificateLoader.LoadPkcs12(cert.Export(X509ContentType.Pkcs12), nullPassword, config.ClientCertificateKeyStoreFlags.Value); +#else + cert = new X509Certificate2(cert.Export(X509ContentType.Pkcs12), nullPassword, config.ClientCertificateKeyStoreFlags.Value); +#endif + } else { - return new X509Certificate2(pkcs.ToArray()); +#if NET9_0_OR_GREATER + cert = X509CertificateLoader.LoadPkcs12(cert.Export(X509ContentType.Pkcs12), nullPassword); +#else + cert = new X509Certificate2(cert.Export(X509ContentType.Pkcs12), nullPassword); +#endif } } -#endif + + return cert; } /// diff --git a/src/KubernetesClient/ClientSets/ClientSet.cs b/src/KubernetesClient/ClientSets/ClientSet.cs new file mode 100644 index 000000000..53aa37df9 --- /dev/null +++ b/src/KubernetesClient/ClientSets/ClientSet.cs @@ -0,0 +1,16 @@ +namespace k8s.ClientSets +{ + /// + /// Represents a base class for clients that interact with Kubernetes resources. + /// Provides shared functionality for derived resource-specific clients. + /// + public partial class ClientSet + { + private readonly Kubernetes _kubernetes; + + public ClientSet(Kubernetes kubernetes) + { + _kubernetes = kubernetes; + } + } +} diff --git a/src/KubernetesClient/ClientSets/ResourceClient.cs b/src/KubernetesClient/ClientSets/ResourceClient.cs new file mode 100644 index 000000000..bbf1c43e8 --- /dev/null +++ b/src/KubernetesClient/ClientSets/ResourceClient.cs @@ -0,0 +1,16 @@ +namespace k8s.ClientSets +{ + /// + /// Represents a set of Kubernetes clients for interacting with the Kubernetes API. + /// This class provides access to various client implementations for managing Kubernetes resources. + /// + public abstract class ResourceClient + { + protected Kubernetes Client { get; } + + public ResourceClient(Kubernetes kubernetes) + { + Client = kubernetes; + } + } +} diff --git a/src/KubernetesClient/ExecAsyncCallback.cs b/src/KubernetesClient/ExecAsyncCallback.cs index 6ad735d22..461f980f2 100644 --- a/src/KubernetesClient/ExecAsyncCallback.cs +++ b/src/KubernetesClient/ExecAsyncCallback.cs @@ -1,6 +1,3 @@ -using System.IO; -using System.Threading.Tasks; - namespace k8s { /// diff --git a/src/KubernetesClient.Models/Extensions.cs b/src/KubernetesClient/Extensions.cs similarity index 98% rename from src/KubernetesClient.Models/Extensions.cs rename to src/KubernetesClient/Extensions.cs index accab5c6d..270a74724 100644 --- a/src/KubernetesClient.Models/Extensions.cs +++ b/src/KubernetesClient/Extensions.cs @@ -1,6 +1,5 @@ using System.Reflection; using System.Text.RegularExpressions; -using k8s.Models; namespace k8s { diff --git a/src/KubernetesClient/FileSystem.cs b/src/KubernetesClient/FileSystem.cs new file mode 100644 index 000000000..4a1e7654e --- /dev/null +++ b/src/KubernetesClient/FileSystem.cs @@ -0,0 +1,55 @@ +namespace k8s +{ + internal static class FileSystem + { + public interface IFileSystem + { + Stream OpenRead(string path); + + bool Exists(string path); + + string ReadAllText(string path); + } + + public static IFileSystem Current { get; private set; } = new RealFileSystem(); + + public static IDisposable With(IFileSystem fileSystem) + { + return new InjectedFileSystem(fileSystem); + } + + private class InjectedFileSystem : IDisposable + { + private readonly IFileSystem _original; + + public InjectedFileSystem(IFileSystem fileSystem) + { + _original = Current; + Current = fileSystem; + } + + public void Dispose() + { + Current = _original; + } + } + + private class RealFileSystem : IFileSystem + { + public bool Exists(string path) + { + return File.Exists(path); + } + + public Stream OpenRead(string path) + { + return File.OpenRead(path); + } + + public string ReadAllText(string path) + { + return File.ReadAllText(path); + } + } + } +} diff --git a/src/KubernetesClient/FileUtils.cs b/src/KubernetesClient/FileUtils.cs deleted file mode 100644 index d6b3f4721..000000000 --- a/src/KubernetesClient/FileUtils.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.IO.Abstractions; - -namespace k8s -{ - public static class FileUtils - { - private static readonly IFileSystem RealFileSystem = new FileSystem(); - private static IFileSystem currentFileSystem = null; - - public static void InjectFilesystem(IFileSystem fs) - { - currentFileSystem = fs; - } - - public static IFileSystem FileSystem() - { - return currentFileSystem != null ? currentFileSystem : RealFileSystem; - } - - public sealed class InjectedFileSystem : IDisposable - { - public InjectedFileSystem(IFileSystem fs) - { - InjectFilesystem(fs); - } - - public void Dispose() - { - InjectFilesystem(null); - } - } - } -} diff --git a/src/KubernetesClient/FloatEmitter.cs b/src/KubernetesClient/FloatEmitter.cs new file mode 100644 index 000000000..4a0f18517 --- /dev/null +++ b/src/KubernetesClient/FloatEmitter.cs @@ -0,0 +1,33 @@ +using System.Globalization; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; +using YamlDotNet.Serialization; +using YamlDotNet.Serialization.EventEmitters; + +namespace k8s +{ + internal class FloatEmitter : ChainedEventEmitter + { + public FloatEmitter(IEventEmitter nextEmitter) + : base(nextEmitter) + { + } + + public override void Emit(ScalarEventInfo eventInfo, IEmitter emitter) + { + switch (eventInfo.Source.Value) + { + // Floating point numbers should always render at least one zero (e.g. 1.0f => '1.0' not '1') + case double d: + emitter.Emit(new Scalar(d.ToString("0.0######################", CultureInfo.InvariantCulture))); + break; + case float f: + emitter.Emit(new Scalar(f.ToString("0.0######################", CultureInfo.InvariantCulture))); + break; + default: + base.Emit(eventInfo, emitter); + break; + } + } + } +} diff --git a/src/KubernetesClient/GeneratedApiVersion.cs b/src/KubernetesClient/GeneratedApiVersion.cs new file mode 100644 index 000000000..f3dbf19c2 --- /dev/null +++ b/src/KubernetesClient/GeneratedApiVersion.cs @@ -0,0 +1,10 @@ +namespace k8s; + +public static class GeneratedApiVersion +{ + // Now API version is the same as model version + // Change this if api is generated from a separate swagger spec + + public const string AssemblyVersion = GeneratedModelVersion.AssemblyVersion; + public const string SwaggerVersion = GeneratedModelVersion.SwaggerVersion; +} diff --git a/src/KubernetesClient/GenericClient.cs b/src/KubernetesClient/GenericClient.cs index 277c6be22..a250aad22 100644 --- a/src/KubernetesClient/GenericClient.cs +++ b/src/KubernetesClient/GenericClient.cs @@ -1,7 +1,3 @@ -using System.Threading; -using System.Threading.Tasks; - - namespace k8s { public class GenericClient : IDisposable @@ -10,6 +6,7 @@ public class GenericClient : IDisposable private readonly string group; private readonly string version; private readonly string plural; + private readonly bool disposeClient; [Obsolete] public GenericClient(KubernetesClientConfiguration config, string group, string version, string plural) @@ -17,73 +14,130 @@ public GenericClient(KubernetesClientConfiguration config, string group, string { } - public GenericClient(IKubernetes kubernetes, string version, string plural) - : this(kubernetes, "", version, plural) + public GenericClient(IKubernetes kubernetes, string version, string plural, bool disposeClient = true) + : this(kubernetes, "", version, plural, disposeClient) { } - public GenericClient(IKubernetes kubernetes, string group, string version, string plural) + public GenericClient(IKubernetes kubernetes, string group, string version, string plural, bool disposeClient = true) { this.group = group; this.version = version; this.plural = plural; this.kubernetes = kubernetes; + this.disposeClient = disposeClient; } public async Task CreateAsync(T obj, CancellationToken cancel = default) where T : IKubernetesObject { - var resp = await kubernetes.CustomObjects.CreateClusterCustomObjectWithHttpMessagesAsync(obj, group, version, plural, cancellationToken: cancel).ConfigureAwait(false); - return KubernetesJson.Deserialize(resp.Body.ToString()); + var resp = await kubernetes.CustomObjects.CreateClusterCustomObjectWithHttpMessagesAsync(obj, group, version, plural, cancellationToken: cancel).ConfigureAwait(false); + return resp.Body; } public async Task CreateNamespacedAsync(T obj, string ns, CancellationToken cancel = default) where T : IKubernetesObject { - var resp = await kubernetes.CustomObjects.CreateNamespacedCustomObjectWithHttpMessagesAsync(obj, group, version, ns, plural, cancellationToken: cancel).ConfigureAwait(false); - return KubernetesJson.Deserialize(resp.Body.ToString()); + var resp = await kubernetes.CustomObjects.CreateNamespacedCustomObjectWithHttpMessagesAsync(obj, group, version, ns, plural, cancellationToken: cancel).ConfigureAwait(false); + return resp.Body; } public async Task ListAsync(CancellationToken cancel = default) where T : IKubernetesObject { - var resp = await kubernetes.CustomObjects.ListClusterCustomObjectWithHttpMessagesAsync(group, version, plural, cancellationToken: cancel).ConfigureAwait(false); - return KubernetesJson.Deserialize(resp.Body.ToString()); + var resp = await kubernetes.CustomObjects.ListClusterCustomObjectWithHttpMessagesAsync(group, version, plural, cancellationToken: cancel).ConfigureAwait(false); + return resp.Body; } public async Task ListNamespacedAsync(string ns, CancellationToken cancel = default) where T : IKubernetesObject { - var resp = await kubernetes.CustomObjects.ListNamespacedCustomObjectWithHttpMessagesAsync(group, version, ns, plural, cancellationToken: cancel).ConfigureAwait(false); - return KubernetesJson.Deserialize(resp.Body.ToString()); + var resp = await kubernetes.CustomObjects.ListNamespacedCustomObjectWithHttpMessagesAsync(group, version, ns, plural, cancellationToken: cancel).ConfigureAwait(false); + return resp.Body; } public async Task ReadNamespacedAsync(string ns, string name, CancellationToken cancel = default) where T : IKubernetesObject { - var resp = await kubernetes.CustomObjects.GetNamespacedCustomObjectWithHttpMessagesAsync(group, version, ns, plural, name, cancellationToken: cancel).ConfigureAwait(false); - return KubernetesJson.Deserialize(resp.Body.ToString()); + var resp = await kubernetes.CustomObjects.GetNamespacedCustomObjectWithHttpMessagesAsync(group, version, ns, plural, name, cancellationToken: cancel).ConfigureAwait(false); + return resp.Body; } public async Task ReadAsync(string name, CancellationToken cancel = default) where T : IKubernetesObject { - var resp = await kubernetes.CustomObjects.GetClusterCustomObjectWithHttpMessagesAsync(group, version, plural, name, cancellationToken: cancel).ConfigureAwait(false); - return KubernetesJson.Deserialize(resp.Body.ToString()); + var resp = await kubernetes.CustomObjects.GetClusterCustomObjectWithHttpMessagesAsync(group, version, plural, name, cancellationToken: cancel).ConfigureAwait(false); + return resp.Body; } public async Task DeleteAsync(string name, CancellationToken cancel = default) where T : IKubernetesObject { - var resp = await kubernetes.CustomObjects.DeleteClusterCustomObjectWithHttpMessagesAsync(group, version, plural, name, cancellationToken: cancel).ConfigureAwait(false); - return KubernetesJson.Deserialize(resp.Body.ToString()); + var resp = await kubernetes.CustomObjects.DeleteClusterCustomObjectWithHttpMessagesAsync(group, version, plural, name, cancellationToken: cancel).ConfigureAwait(false); + return resp.Body; } public async Task DeleteNamespacedAsync(string ns, string name, CancellationToken cancel = default) where T : IKubernetesObject { - var resp = await kubernetes.CustomObjects.DeleteNamespacedCustomObjectWithHttpMessagesAsync(group, version, ns, plural, name, cancellationToken: cancel).ConfigureAwait(false); - return KubernetesJson.Deserialize(resp.Body.ToString()); + var resp = await kubernetes.CustomObjects.DeleteNamespacedCustomObjectWithHttpMessagesAsync(group, version, ns, plural, name, cancellationToken: cancel).ConfigureAwait(false); + return resp.Body; + } + + public async Task PatchAsync(V1Patch patch, string name, CancellationToken cancel = default) + where T : IKubernetesObject + { + var resp = await kubernetes.CustomObjects.PatchClusterCustomObjectWithHttpMessagesAsync(patch, group, version, plural, name, cancellationToken: cancel).ConfigureAwait(false); + return resp.Body; + } + + public async Task PatchNamespacedAsync(V1Patch patch, string ns, string name, CancellationToken cancel = default) + where T : IKubernetesObject + { + var resp = await kubernetes.CustomObjects.PatchNamespacedCustomObjectWithHttpMessagesAsync(patch, group, version, ns, plural, name, cancellationToken: cancel).ConfigureAwait(false); + return resp.Body; + } + + public async Task ReplaceAsync(T obj, string name, CancellationToken cancel = default) + where T : IKubernetesObject + { + var resp = await kubernetes.CustomObjects.ReplaceClusterCustomObjectWithHttpMessagesAsync(obj, group, version, plural, name, cancellationToken: cancel).ConfigureAwait(false); + return resp.Body; + } + + public async Task ReplaceNamespacedAsync(T obj, string ns, string name, CancellationToken cancel = default) + where T : IKubernetesObject + { + var resp = await kubernetes.CustomObjects.ReplaceNamespacedCustomObjectWithHttpMessagesAsync(obj, group, version, ns, plural, name, cancellationToken: cancel).ConfigureAwait(false); + return resp.Body; + } + + public IAsyncEnumerable<(WatchEventType, T)> WatchAsync(Action onError = null, CancellationToken cancel = default) + where T : IKubernetesObject + { + var respTask = kubernetes.CustomObjects.ListClusterCustomObjectWithHttpMessagesAsync(group, version, plural, watch: true, cancellationToken: cancel); + return respTask.WatchAsync(onError, cancel); + } + + public IAsyncEnumerable<(WatchEventType, T)> WatchNamespacedAsync(string ns, Action onError = null, CancellationToken cancel = default) + where T : IKubernetesObject + { + var respTask = kubernetes.CustomObjects.ListNamespacedCustomObjectWithHttpMessagesAsync(group, version, ns, plural, watch: true, cancellationToken: cancel); + return respTask.WatchAsync(onError, cancel); + } + + public Watcher Watch(Action onEvent, Action onError = null, Action onClosed = null) + where T : IKubernetesObject + { + var respTask = kubernetes.CustomObjects.ListClusterCustomObjectWithHttpMessagesAsync(group, version, plural, watch: true); + return respTask.Watch(onEvent, onError, onClosed); + } + + public Watcher WatchNamespaced(string ns, Action onEvent, Action onError = null, Action onClosed = null) + where T : IKubernetesObject + { + var respTask = kubernetes.CustomObjects.ListNamespacedCustomObjectWithHttpMessagesAsync(group, version, ns, plural, watch: true); + return respTask.Watch(onEvent, onError, onClosed); } public void Dispose() @@ -94,7 +148,10 @@ public void Dispose() protected virtual void Dispose(bool disposing) { - kubernetes.Dispose(); + if (disposeClient) + { + kubernetes.Dispose(); + } } } } diff --git a/src/KubernetesClient/Global.cs b/src/KubernetesClient/Global.cs index 70b3700e1..2b5a4ae8e 100644 --- a/src/KubernetesClient/Global.cs +++ b/src/KubernetesClient/Global.cs @@ -1,5 +1,10 @@ +global using k8s.Autorest; +global using k8s.Models; global using System; global using System.Collections.Generic; +global using System.IO; global using System.Linq; global using System.Text.Json; global using System.Text.Json.Serialization; +global using System.Threading; +global using System.Threading.Tasks; diff --git a/src/KubernetesClient/IKubernetes.Exec.cs b/src/KubernetesClient/IKubernetes.Exec.cs index 89d64d4da..b9197a897 100644 --- a/src/KubernetesClient/IKubernetes.Exec.cs +++ b/src/KubernetesClient/IKubernetes.Exec.cs @@ -1,6 +1,3 @@ -using System.Threading; -using System.Threading.Tasks; - namespace k8s { public partial interface IKubernetes diff --git a/src/KubernetesClient/IKubernetes.WebSocket.cs b/src/KubernetesClient/IKubernetes.WebSocket.cs index e5976efe6..ed6657332 100644 --- a/src/KubernetesClient/IKubernetes.WebSocket.cs +++ b/src/KubernetesClient/IKubernetes.WebSocket.cs @@ -1,6 +1,4 @@ using System.Net.WebSockets; -using System.Threading; -using System.Threading.Tasks; namespace k8s { diff --git a/src/KubernetesClient/IKubernetes.cs b/src/KubernetesClient/IKubernetes.cs index c3f871d64..5fa42e955 100644 --- a/src/KubernetesClient/IKubernetes.cs +++ b/src/KubernetesClient/IKubernetes.cs @@ -1,6 +1,6 @@ namespace k8s; -public partial interface IKubernetes : IBasicKubernetes, IDisposable +public partial interface IKubernetes : IDisposable { /// /// The base URI of the service. diff --git a/src/KubernetesClient.Models/IKubernetesObject.cs b/src/KubernetesClient/IKubernetesObject.cs similarity index 100% rename from src/KubernetesClient.Models/IKubernetesObject.cs rename to src/KubernetesClient/IKubernetesObject.cs diff --git a/src/KubernetesClient/IStreamDemuxer.cs b/src/KubernetesClient/IStreamDemuxer.cs index 406e086c0..ce46d40f8 100644 --- a/src/KubernetesClient/IStreamDemuxer.cs +++ b/src/KubernetesClient/IStreamDemuxer.cs @@ -1,19 +1,15 @@ -using System.IO; -using System.Threading; -using System.Threading.Tasks; - namespace k8s { /// /// /// The interface allows you to interact with processes running in a container in a Kubernetes pod. You can start an exec or attach command - /// by calling - /// or . These methods - /// will return you a connection. + /// by calling + /// or . These methods + /// will return you a connection. /// /// - /// Kubernetes 'multiplexes' multiple channels over this connection, such as standard input, standard output and standard error. The - /// allows you to extract individual s from this class. You can then use these streams to send/receive data from that process. + /// Kubernetes 'multiplexes' multiple channels over this connection, such as standard input, standard output and standard error. The + /// allows you to extract individual s from this . You can then use these streams to send/receive data from that process. /// /// public interface IStreamDemuxer : IDisposable diff --git a/src/KubernetesClient.Models/KubeConfigModels/AuthProvider.cs b/src/KubernetesClient/KubeConfigModels/AuthProvider.cs similarity index 100% rename from src/KubernetesClient.Models/KubeConfigModels/AuthProvider.cs rename to src/KubernetesClient/KubeConfigModels/AuthProvider.cs diff --git a/src/KubernetesClient.Models/KubeConfigModels/Cluster.cs b/src/KubernetesClient/KubeConfigModels/Cluster.cs similarity index 100% rename from src/KubernetesClient.Models/KubeConfigModels/Cluster.cs rename to src/KubernetesClient/KubeConfigModels/Cluster.cs diff --git a/src/KubernetesClient.Models/KubeConfigModels/ClusterEndpoint.cs b/src/KubernetesClient/KubeConfigModels/ClusterEndpoint.cs similarity index 87% rename from src/KubernetesClient.Models/KubeConfigModels/ClusterEndpoint.cs rename to src/KubernetesClient/KubeConfigModels/ClusterEndpoint.cs index 4838d0083..cdd791b4a 100644 --- a/src/KubernetesClient.Models/KubeConfigModels/ClusterEndpoint.cs +++ b/src/KubernetesClient/KubeConfigModels/ClusterEndpoint.cs @@ -25,6 +25,12 @@ public class ClusterEndpoint [YamlMember(Alias = "server")] public string Server { get; set; } + /// + /// Gets or sets a value to override the TLS server name. + /// + [YamlMember(Alias = "tls-server-name", ApplyNamingConventions = false)] + public string TlsServerName { get; set; } + /// /// Gets or sets a value indicating whether to skip the validity check for the server's certificate. /// This will make your HTTPS connections insecure. diff --git a/src/KubernetesClient.Models/KubeConfigModels/Context.cs b/src/KubernetesClient/KubeConfigModels/Context.cs similarity index 100% rename from src/KubernetesClient.Models/KubeConfigModels/Context.cs rename to src/KubernetesClient/KubeConfigModels/Context.cs diff --git a/src/KubernetesClient.Models/KubeConfigModels/ContextDetails.cs b/src/KubernetesClient/KubeConfigModels/ContextDetails.cs similarity index 100% rename from src/KubernetesClient.Models/KubeConfigModels/ContextDetails.cs rename to src/KubernetesClient/KubeConfigModels/ContextDetails.cs diff --git a/src/KubernetesClient.Models/KubeConfigModels/ExecCredentialResponse.cs b/src/KubernetesClient/KubeConfigModels/ExecCredentialResponse.cs similarity index 88% rename from src/KubernetesClient.Models/KubeConfigModels/ExecCredentialResponse.cs rename to src/KubernetesClient/KubeConfigModels/ExecCredentialResponse.cs index 57c916ef9..6654ba3bd 100644 --- a/src/KubernetesClient.Models/KubeConfigModels/ExecCredentialResponse.cs +++ b/src/KubernetesClient/KubeConfigModels/ExecCredentialResponse.cs @@ -13,8 +13,8 @@ public class ExecStatus public bool IsValid() { - return (!string.IsNullOrEmpty(Token) || - (!string.IsNullOrEmpty(ClientCertificateData) && !string.IsNullOrEmpty(ClientKeyData))); + return !string.IsNullOrEmpty(Token) || + (!string.IsNullOrEmpty(ClientCertificateData) && !string.IsNullOrEmpty(ClientKeyData)); } } diff --git a/src/KubernetesClient.Models/KubeConfigModels/ExternalExecution.cs b/src/KubernetesClient/KubeConfigModels/ExternalExecution.cs similarity index 100% rename from src/KubernetesClient.Models/KubeConfigModels/ExternalExecution.cs rename to src/KubernetesClient/KubeConfigModels/ExternalExecution.cs diff --git a/src/KubernetesClient.Models/KubeConfigModels/K8SConfiguration.cs b/src/KubernetesClient/KubeConfigModels/K8SConfiguration.cs similarity index 100% rename from src/KubernetesClient.Models/KubeConfigModels/K8SConfiguration.cs rename to src/KubernetesClient/KubeConfigModels/K8SConfiguration.cs diff --git a/src/KubernetesClient.Models/KubeConfigModels/NamedExtension.cs b/src/KubernetesClient/KubeConfigModels/NamedExtension.cs similarity index 100% rename from src/KubernetesClient.Models/KubeConfigModels/NamedExtension.cs rename to src/KubernetesClient/KubeConfigModels/NamedExtension.cs diff --git a/src/KubernetesClient.Models/KubeConfigModels/User.cs b/src/KubernetesClient/KubeConfigModels/User.cs similarity index 100% rename from src/KubernetesClient.Models/KubeConfigModels/User.cs rename to src/KubernetesClient/KubeConfigModels/User.cs diff --git a/src/KubernetesClient.Models/KubeConfigModels/UserCredentials.cs b/src/KubernetesClient/KubeConfigModels/UserCredentials.cs similarity index 100% rename from src/KubernetesClient.Models/KubeConfigModels/UserCredentials.cs rename to src/KubernetesClient/KubeConfigModels/UserCredentials.cs diff --git a/src/KubernetesClient/Kubernetes.ConfigInit.cs b/src/KubernetesClient/Kubernetes.ConfigInit.cs index ee155e28b..e87e4e96a 100644 --- a/src/KubernetesClient/Kubernetes.ConfigInit.cs +++ b/src/KubernetesClient/Kubernetes.ConfigInit.cs @@ -1,14 +1,15 @@ +using k8s.Authentication; +using k8s.Exceptions; using System.Net.Http; using System.Net.Security; using System.Security.Cryptography.X509Certificates; -using System.Threading; -using k8s.Exceptions; -using k8s.Autorest; namespace k8s { public partial class Kubernetes { + private readonly JsonSerializerOptions jsonSerializerOptions; + /// /// Initializes a new instance of the class. /// @@ -22,11 +23,27 @@ public Kubernetes(KubernetesClientConfiguration config, params DelegatingHandler { Initialize(); ValidateConfig(config); - CaCerts = config.SslCaCerts; + + if (config.SslCaCerts != null) + { + var caCerts = new X509Certificate2Collection(); + foreach (var cert in config.SslCaCerts) + { + caCerts.Add(new X509Certificate2(cert)); + } + + CaCerts = caCerts; + } + SkipTlsVerify = config.SkipTlsVerify; + TlsServerName = config.TlsServerName; CreateHttpClient(handlers, config); InitializeFromConfig(config); HttpClientTimeout = config.HttpClientTimeout; + jsonSerializerOptions = config.JsonSerializerOptions; +#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER + DisableHttp2 = config.DisableHttp2; +#endif } private void ValidateConfig(KubernetesClientConfiguration config) @@ -66,44 +83,51 @@ private void InitializeFromConfig(KubernetesClientConfiguration config) } else { - if (CaCerts == null) + if (CaCerts != null) { - throw new KubeConfigException("A CA must be set when SkipTlsVerify === false"); - } - #if NET5_0_OR_GREATER - HttpClientHandler.SslOptions.RemoteCertificateValidationCallback = + HttpClientHandler.SslOptions.RemoteCertificateValidationCallback = #else - HttpClientHandler.ServerCertificateCustomValidationCallback = + HttpClientHandler.ServerCertificateCustomValidationCallback = #endif - (sender, certificate, chain, sslPolicyErrors) => - { - return CertificateValidationCallBack(sender, CaCerts, certificate, chain, - sslPolicyErrors); - }; + (sender, certificate, chain, sslPolicyErrors) => + { + return CertificateValidationCallBack(sender, CaCerts, certificate, chain, + sslPolicyErrors); + }; + } } } // set credentails for the kubernetes client SetCredentials(config); - var clientCert = CertUtils.GetClientCert(config); - if (clientCert != null) + ClientCert = CertUtils.GetClientCert(config); + if (ClientCert != null) { #if NET5_0_OR_GREATER - HttpClientHandler.SslOptions.ClientCertificates.Add(clientCert); + HttpClientHandler.SslOptions.ClientCertificates.Add(ClientCert); + + // TODO this is workaround for net7.0, remove it when the issue is fixed + // seems the client certificate is cached and cannot be updated + HttpClientHandler.SslOptions.LocalCertificateSelectionCallback = (sender, targetHost, localCertificates, remoteCertificate, acceptableIssuers) => + { + return ClientCert; + }; #else - HttpClientHandler.ClientCertificates.Add(clientCert); + HttpClientHandler.ClientCertificates.Add(ClientCert); #endif } } private X509Certificate2Collection CaCerts { get; } - private X509Certificate2 ClientCert { get; } + private X509Certificate2 ClientCert { get; set; } private bool SkipTlsVerify { get; } + private string TlsServerName { get; } + // NOTE: this method replicates the logic that the base ServiceClient uses except that it doesn't insert the RetryDelegatingHandler // and it does insert the WatcherDelegatingHandler. we don't want the RetryDelegatingHandler because it has a very broad definition // of what requests have failed. it considers everything outside 2xx to be failed, including 1xx (e.g. 101 Switching Protocols) and @@ -116,6 +140,7 @@ private void CreateHttpClient(DelegatingHandler[] handlers, KubernetesClientConf KeepAlivePingPolicy = HttpKeepAlivePingPolicy.WithActiveRequests, KeepAlivePingDelay = TimeSpan.FromMinutes(3), KeepAlivePingTimeout = TimeSpan.FromSeconds(30), + EnableMultipleHttp2Connections = true, }; HttpClientHandler.SslOptions.ClientCertificates = new X509Certificate2Collection(); @@ -145,8 +170,6 @@ private void CreateHttpClient(DelegatingHandler[] handlers, KubernetesClientConf }; } - - /// /// Set credentials for the Client /// @@ -190,11 +213,13 @@ public static bool CertificateValidationCallBack( { chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; - // Added our trusted certificates to the chain - // - chain.ChainPolicy.ExtraStore.AddRange(caCerts); - - chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllowUnknownCertificateAuthority; +#if NET5_0_OR_GREATER + // Use custom trust store only, ignore system root CA + chain.ChainPolicy.CustomTrustStore.AddRange(caCerts); + chain.ChainPolicy.TrustMode = X509ChainTrustMode.CustomRootTrust; +#else + throw new NotSupportedException("Custom trust store requires .NET 5.0 or later. Current platform does not support this feature."); +#endif var isValid = chain.Build((X509Certificate2)certificate); var isTrusted = false; diff --git a/src/KubernetesClient/Kubernetes.Exec.cs b/src/KubernetesClient/Kubernetes.Exec.cs index 240d8cc46..53671aead 100644 --- a/src/KubernetesClient/Kubernetes.Exec.cs +++ b/src/KubernetesClient/Kubernetes.Exec.cs @@ -1,9 +1,3 @@ -using k8s.Models; -using k8s.Autorest; -using System.IO; -using System.Threading; -using System.Threading.Tasks; - namespace k8s { public partial class Kubernetes @@ -19,31 +13,31 @@ public async Task NamespacedPodExecAsync(string name, string @namespace, st try { - using (var muxedStream = await MuxedStreamNamespacedPodExecAsync( + using var muxedStream = await MuxedStreamNamespacedPodExecAsync( name, @namespace, command, container, tty: tty, - cancellationToken: cancellationToken).ConfigureAwait(false)) - using (var stdIn = muxedStream.GetStream(null, ChannelIndex.StdIn)) - using (var stdOut = muxedStream.GetStream(ChannelIndex.StdOut, null)) - using (var stdErr = muxedStream.GetStream(ChannelIndex.StdErr, null)) - using (var error = muxedStream.GetStream(ChannelIndex.Error, null)) - using (var errorReader = new StreamReader(error)) - { - muxedStream.Start(); + cancellationToken: cancellationToken).ConfigureAwait(false); - await action(stdIn, stdOut, stdErr).ConfigureAwait(false); + using var stdIn = muxedStream.GetStream(null, ChannelIndex.StdIn); + using var stdOut = muxedStream.GetStream(ChannelIndex.StdOut, null); + using var stdErr = muxedStream.GetStream(ChannelIndex.StdErr, null); + using var error = muxedStream.GetStream(ChannelIndex.Error, null); + using var errorReader = new StreamReader(error); - var errors = await errorReader.ReadToEndAsync().ConfigureAwait(false); + muxedStream.Start(); - // StatusError is defined here: - // https://github.com/kubernetes/kubernetes/blob/068e1642f63a1a8c48c16c18510e8854a4f4e7c5/staging/src/k8s.io/apimachinery/pkg/api/errors/errors.go#L37 - var returnMessage = KubernetesJson.Deserialize(errors); - return GetExitCodeOrThrow(returnMessage); - } + await action(stdIn, stdOut, stdErr).ConfigureAwait(false); + + var errors = await errorReader.ReadToEndAsync().ConfigureAwait(false); + + // StatusError is defined here: + // https://github.com/kubernetes/kubernetes/blob/068e1642f63a1a8c48c16c18510e8854a4f4e7c5/staging/src/k8s.io/apimachinery/pkg/api/errors/errors.go#L37 + var returnMessage = KubernetesJson.Deserialize(errors); + return GetExitCodeOrThrow(returnMessage); } - catch (HttpOperationException httpEx) when (httpEx.Body is V1Status) + catch (HttpOperationException httpEx) when (httpEx.Body is V1Status status) { - throw new KubernetesException((V1Status)httpEx.Body, httpEx); + throw new KubernetesException(status, httpEx); } } diff --git a/src/KubernetesClient/Kubernetes.WebSocket.cs b/src/KubernetesClient/Kubernetes.WebSocket.cs index abcae21f2..aeca29708 100644 --- a/src/KubernetesClient/Kubernetes.WebSocket.cs +++ b/src/KubernetesClient/Kubernetes.WebSocket.cs @@ -1,13 +1,9 @@ -using k8s.Models; -using k8s.Autorest; +using System.Globalization; using System.Net; using System.Net.Http; using System.Net.WebSockets; using System.Security.Cryptography.X509Certificates; -using System.Threading; -using System.Threading.Tasks; using System.Text; -using System.Globalization; namespace k8s { @@ -22,11 +18,11 @@ public partial class Kubernetes /// public Task WebSocketNamespacedPodExecAsync(string name, string @namespace = "default", string command = null, string container = null, bool stderr = true, bool stdin = true, bool stdout = true, - bool tty = true, string webSocketSubProtol = null, Dictionary> customHeaders = null, + bool tty = true, string webSocketSubProtocol = null, Dictionary> customHeaders = null, CancellationToken cancellationToken = default) { return WebSocketNamespacedPodExecAsync(name, @namespace, new string[] { command }, container, stderr, stdin, - stdout, tty, webSocketSubProtol, customHeaders, cancellationToken); + stdout, tty, webSocketSubProtocol, customHeaders, cancellationToken); } /// @@ -34,7 +30,7 @@ public virtual async Task MuxedStreamNamespacedPodExecAsync( string name, string @namespace = "default", IEnumerable command = null, string container = null, bool stderr = true, bool stdin = true, bool stdout = true, bool tty = true, - string webSocketSubProtol = WebSocketProtocol.V4BinaryWebsocketProtocol, + string webSocketSubProtocol = WebSocketProtocol.V4BinaryWebsocketProtocol, Dictionary> customHeaders = null, CancellationToken cancellationToken = default) { @@ -49,7 +45,7 @@ public virtual async Task MuxedStreamNamespacedPodExecAsync( public virtual Task WebSocketNamespacedPodExecAsync(string name, string @namespace = "default", IEnumerable command = null, string container = null, bool stderr = true, bool stdin = true, bool stdout = true, bool tty = true, - string webSocketSubProtol = WebSocketProtocol.V4BinaryWebsocketProtocol, + string webSocketSubProtocol = WebSocketProtocol.V4BinaryWebsocketProtocol, Dictionary> customHeaders = null, CancellationToken cancellationToken = default) { @@ -84,8 +80,10 @@ public virtual Task WebSocketNamespacedPodExecAsync(string name, stri } // Construct URL - var uriBuilder = new UriBuilder(BaseUri); - uriBuilder.Scheme = BaseUri.Scheme == "https" ? "wss" : "ws"; + var uriBuilder = new UriBuilder(BaseUri) + { + Scheme = BaseUri.Scheme == "https" ? "wss" : "ws", + }; if (!uriBuilder.Path.EndsWith("/", StringComparison.InvariantCulture)) { @@ -116,7 +114,7 @@ public virtual Task WebSocketNamespacedPodExecAsync(string name, stri uriBuilder.Query = query.ToString(1, query.Length - 1); // UriBuilder.Query doesn't like leading '?' chars, so trim it - return StreamConnectAsync(uriBuilder.Uri, webSocketSubProtol, customHeaders, + return StreamConnectAsync(uriBuilder.Uri, webSocketSubProtocol, customHeaders, cancellationToken); } @@ -143,8 +141,10 @@ public Task WebSocketNamespacedPodPortForwardAsync(string name, strin // Construct URL - var uriBuilder = new UriBuilder(BaseUri); - uriBuilder.Scheme = BaseUri.Scheme == "https" ? "wss" : "ws"; + var uriBuilder = new UriBuilder(BaseUri) + { + Scheme = BaseUri.Scheme == "https" ? "wss" : "ws", + }; if (!uriBuilder.Path.EndsWith("/", StringComparison.InvariantCulture)) { @@ -173,7 +173,7 @@ public Task WebSocketNamespacedPodPortForwardAsync(string name, strin /// public Task WebSocketNamespacedPodAttachAsync(string name, string @namespace, string container = default, bool stderr = true, bool stdin = false, bool stdout = true, - bool tty = false, string webSocketSubProtol = null, Dictionary> customHeaders = null, + bool tty = false, string webSocketSubProtocol = null, Dictionary> customHeaders = null, CancellationToken cancellationToken = default) { if (name == null) @@ -187,8 +187,10 @@ public Task WebSocketNamespacedPodAttachAsync(string name, string @na } // Construct URL - var uriBuilder = new UriBuilder(BaseUri); - uriBuilder.Scheme = BaseUri.Scheme == "https" ? "wss" : "ws"; + var uriBuilder = new UriBuilder(BaseUri) + { + Scheme = BaseUri.Scheme == "https" ? "wss" : "ws", + }; if (!uriBuilder.Path.EndsWith("/", StringComparison.InvariantCulture)) { @@ -206,7 +208,7 @@ public Task WebSocketNamespacedPodAttachAsync(string name, string @na uriBuilder.Query = query.ToString(1, query.Length - 1); // UriBuilder.Query doesn't like leading '?' chars, so trim it - return StreamConnectAsync(uriBuilder.Uri, webSocketSubProtol, customHeaders, + return StreamConnectAsync(uriBuilder.Uri, webSocketSubProtocol, customHeaders, cancellationToken); } @@ -233,11 +235,6 @@ protected async Task StreamConnectAsync(Uri uri, string webSocketSubP } // Set Credentials - if (this.ClientCert != null) - { - webSocketBuilder.AddClientCertificate(this.ClientCert); - } - if (this.HttpClientHandler != null) { #if NET5_0_OR_GREATER @@ -284,8 +281,7 @@ protected async Task StreamConnectAsync(Uri uri, string webSocketSubP try { BeforeRequest(); - webSocket = await webSocketBuilder.BuildAndConnectAsync(uri, CancellationToken.None) - .ConfigureAwait(false); + webSocket = await webSocketBuilder.BuildAndConnectAsync(uri, cancellationToken).ConfigureAwait(false); } catch (WebSocketException wse) when (wse.WebSocketErrorCode == WebSocketError.HeaderError || (wse.InnerException is WebSocketException && @@ -294,8 +290,10 @@ protected async Task StreamConnectAsync(Uri uri, string webSocketSubP { // This usually indicates the server sent an error message, like 400 Bad Request. Unfortunately, the WebSocket client // class doesn't give us a lot of information about what went wrong. So, retry the connection. - var uriBuilder = new UriBuilder(uri); - uriBuilder.Scheme = uri.Scheme == "wss" ? "https" : "http"; + var uriBuilder = new UriBuilder(uri) + { + Scheme = uri.Scheme == "wss" ? "https" : "http", + }; var response = await HttpClient.GetAsync(uriBuilder.Uri, cancellationToken).ConfigureAwait(false); @@ -327,7 +325,7 @@ protected async Task StreamConnectAsync(Uri uri, string webSocketSubP $"The operation returned an invalid status code: {response.StatusCode}", wse) { Response = new HttpResponseMessageWrapper(response, content), - Body = status != null ? (object)status : content, + Body = status != null ? status : content, }; response.Dispose(); diff --git a/src/KubernetesClient/Kubernetes.cs b/src/KubernetesClient/Kubernetes.cs index 9239bbff8..5e5021356 100644 --- a/src/KubernetesClient/Kubernetes.cs +++ b/src/KubernetesClient/Kubernetes.cs @@ -1,9 +1,6 @@ -using System.IO; +using k8s.Authentication; using System.Net; using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using k8s.Autorest; namespace k8s { @@ -47,6 +44,10 @@ public Uri BaseUri private HttpClientHandler HttpClientHandler { get; set; } #endif +#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER + private bool DisableHttp2 { get; set; } +#endif + /// /// Initializes client properties. /// @@ -71,11 +72,7 @@ protected override async Task> CreateResultAsync(Htt if (watch == true) { -#if NETSTANDARD2_0 || NET48 - throw new KubernetesException("watch not supported"); -#else httpResponse.Content = new LineSeparatedHttpContent(httpResponse.Content, cancellationToken); -#endif } try @@ -86,7 +83,7 @@ protected override async Task> CreateResultAsync(Htt using (Stream stream = await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false)) #endif { - result.Body = KubernetesJson.Deserialize(stream); + result.Body = KubernetesJson.Deserialize(stream, jsonSerializerOptions); } } catch (JsonException) @@ -99,13 +96,19 @@ protected override async Task> CreateResultAsync(Htt return result; } - protected override HttpRequestMessage CreateRequest(string relativeUri, HttpMethod method, IReadOnlyDictionary> customHeaders) + protected override Task SendRequest(string relativeUri, HttpMethod method, IReadOnlyDictionary> customHeaders, T body, CancellationToken cancellationToken) { - var httpRequest = new HttpRequestMessage(); - httpRequest.Method = method; - httpRequest.RequestUri = new Uri(BaseUri, relativeUri); + var httpRequest = new HttpRequestMessage + { + Method = method, + RequestUri = new Uri(BaseUri, relativeUri), + }; + #if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER - httpRequest.Version = HttpVersion.Version20; + if (!DisableHttp2) + { + httpRequest.Version = HttpVersion.Version20; + } #endif // Set Headers if (customHeaders != null) @@ -117,10 +120,18 @@ protected override HttpRequestMessage CreateRequest(string relativeUri, HttpMeth } } - return httpRequest; + if (body != null) + { + var requestContent = KubernetesJson.Serialize(body, jsonSerializerOptions); + httpRequest.Content = new StringContent(requestContent, System.Text.Encoding.UTF8); + httpRequest.Content.Headers.ContentType = GetHeader(body); + return SendRequestRaw(requestContent, httpRequest, cancellationToken); + } + + return SendRequestRaw("", httpRequest, cancellationToken); } - protected override async Task SendRequestRaw(string requestContent, HttpRequestMessage httpRequest, CancellationToken cancellationToken) + protected virtual async Task SendRequestRaw(string requestContent, HttpRequestMessage httpRequest, CancellationToken cancellationToken) { if (httpRequest == null) { @@ -134,6 +145,11 @@ protected override async Task SendRequestRaw(string request await Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); } + if (!string.IsNullOrWhiteSpace(TlsServerName)) + { + httpRequest.Headers.Host = TlsServerName; + } + // Send Request cancellationToken.ThrowIfCancellationRequested(); var httpResponse = await HttpClient.SendAsync(httpRequest, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); @@ -143,7 +159,6 @@ protected override async Task SendRequestRaw(string request if (!httpResponse.IsSuccessStatusCode) { string responseContent = null; - var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", statusCode)); if (httpResponse.Content != null) { responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); @@ -153,6 +168,7 @@ protected override async Task SendRequestRaw(string request responseContent = string.Empty; } + var ex = new HttpOperationException($"Operation returned an invalid status code '{statusCode}', response body {responseContent}"); ex.Request = new HttpRequestMessageWrapper(httpRequest, requestContent); ex.Response = new HttpResponseMessageWrapper(httpResponse, responseContent); httpRequest.Dispose(); @@ -187,14 +203,32 @@ public void Dispose() /// True to release both managed and unmanaged resources; false to releases only unmanaged resources. protected virtual void Dispose(bool disposing) { - if (!_disposed) + if (disposing && !_disposed) { _disposed = true; // Dispose the client HttpClient?.Dispose(); HttpClient = null; + + // Dispose the certificates + if (CaCerts is not null) + { + foreach (var caCert in CaCerts) + { + caCert.Dispose(); + } + + CaCerts.Clear(); + } + + ClientCert?.Dispose(); + ClientCert = null; + + FirstMessageHandler?.Dispose(); FirstMessageHandler = null; + + HttpClientHandler?.Dispose(); HttpClientHandler = null; } } diff --git a/src/KubernetesClient/KubernetesClient.csproj b/src/KubernetesClient/KubernetesClient.csproj index 43637d798..dba319136 100644 --- a/src/KubernetesClient/KubernetesClient.csproj +++ b/src/KubernetesClient/KubernetesClient.csproj @@ -1,29 +1,22 @@ - - netstandard2.1;net5.0;net6.0 - k8s - + + net8.0;net9.0 + k8s + true + - - - - - - + + + + - - - - - + + + - - - - - - - + + + diff --git a/src/KubernetesClient/KubernetesClientConfiguration.ConfigFile.cs b/src/KubernetesClient/KubernetesClientConfiguration.ConfigFile.cs index cf0172d1c..f25c55bbb 100644 --- a/src/KubernetesClient/KubernetesClientConfiguration.ConfigFile.cs +++ b/src/KubernetesClient/KubernetesClientConfiguration.ConfigFile.cs @@ -2,11 +2,10 @@ using k8s.Exceptions; using k8s.KubeConfigModels; using System.Diagnostics; -using System.IO; using System.Net; using System.Runtime.InteropServices; using System.Security.Cryptography.X509Certificates; -using System.Threading.Tasks; +using System.Text; namespace k8s { @@ -28,6 +27,16 @@ public partial class KubernetesClientConfiguration // For testing internal static string KubeConfigEnvironmentVariable { get; set; } = "KUBECONFIG"; + /// + /// Exec process timeout + /// + public static TimeSpan ExecTimeout { get; set; } = TimeSpan.FromMinutes(2); + + /// + /// Exec process Standard Errors + /// + public static event EventHandler ExecStdError; + /// /// Initializes a new instance of the from default locations /// If the KUBECONFIG environment variable is set, then that will be used. @@ -61,8 +70,11 @@ public static KubernetesClientConfiguration BuildDefaultConfig() return InClusterConfig(); } - var config = new KubernetesClientConfiguration(); - config.Host = "http://localhost:8080/"; + var config = new KubernetesClientConfiguration + { + Host = "http://localhost:8080/", + }; + return config; } @@ -264,6 +276,7 @@ private void SetClusterDetails(K8SConfiguration k8SConfig, Context activeContext Host = clusterDetails.ClusterEndpoint.Server; SkipTlsVerify = clusterDetails.ClusterEndpoint.SkipTlsVerify; + TlsServerName = clusterDetails.ClusterEndpoint.TlsServerName; if (!Uri.TryCreate(Host, UriKind.Absolute, out var uri)) { @@ -274,14 +287,18 @@ private void SetClusterDetails(K8SConfiguration k8SConfig, Context activeContext { if (IPAddress.Equals(IPAddress.Any, ipAddress)) { - var builder = new UriBuilder(Host); - builder.Host = $"{IPAddress.Loopback}"; + var builder = new UriBuilder(Host) + { + Host = $"{IPAddress.Loopback}", + }; Host = builder.ToString(); } else if (IPAddress.Equals(IPAddress.IPv6Any, ipAddress)) { - var builder = new UriBuilder(Host); - builder.Host = $"{IPAddress.IPv6Loopback}"; + var builder = new UriBuilder(Host) + { + Host = $"{IPAddress.IPv6Loopback}", + }; Host = builder.ToString(); } } @@ -291,13 +308,26 @@ private void SetClusterDetails(K8SConfiguration k8SConfig, Context activeContext if (!string.IsNullOrEmpty(clusterDetails.ClusterEndpoint.CertificateAuthorityData)) { var data = clusterDetails.ClusterEndpoint.CertificateAuthorityData; - SslCaCerts = new X509Certificate2Collection(new X509Certificate2(Convert.FromBase64String(data))); +#if NET9_0_OR_GREATER + SslCaCerts = new X509Certificate2Collection(X509CertificateLoader.LoadCertificate(Convert.FromBase64String(data))); +#else + string nullPassword = null; + // This null password is to change the constructor to fix this KB: + // https://support.microsoft.com/en-us/topic/kb5025823-change-in-how-net-applications-import-x-509-certificates-bf81c936-af2b-446e-9f7a-016f4713b46b + SslCaCerts = new X509Certificate2Collection(new X509Certificate2(Convert.FromBase64String(data), nullPassword)); +#endif } else if (!string.IsNullOrEmpty(clusterDetails.ClusterEndpoint.CertificateAuthority)) { +#if NET9_0_OR_GREATER + SslCaCerts = new X509Certificate2Collection(X509CertificateLoader.LoadCertificateFromFile(GetFullPath( + k8SConfig, + clusterDetails.ClusterEndpoint.CertificateAuthority))); +#else SslCaCerts = new X509Certificate2Collection(new X509Certificate2(GetFullPath( k8SConfig, clusterDetails.ClusterEndpoint.CertificateAuthority))); +#endif } } } @@ -365,45 +395,10 @@ private void SetUserDetails(K8SConfiguration k8SConfig, Context activeContext) switch (userDetails.UserCredentials.AuthProvider.Name) { case "azure": - { - var config = userDetails.UserCredentials.AuthProvider.Config; - if (config.ContainsKey("expires-on")) - { - var expiresOn = int.Parse(config["expires-on"]); - DateTimeOffset expires; - expires = DateTimeOffset.FromUnixTimeSeconds(expiresOn); - - if (DateTimeOffset.Compare( - expires, - DateTimeOffset.Now) - <= 0) - { - var tenantId = config["tenant-id"]; - var clientId = config["client-id"]; - var apiServerId = config["apiserver-id"]; - var refresh = config["refresh-token"]; - var newToken = RenewAzureToken( - tenantId, - clientId, - apiServerId, - refresh); - config["access-token"] = newToken; - } - } - - AccessToken = config["access-token"]; - userCredentialsFound = true; - break; - } + throw new Exception("Please use the https://github.com/Azure/kubelogin credential plugin instead. See https://kubernetes.io/docs/reference/access-authn-authz/authentication/#client-go-credential-plugins for further details`"); case "gcp": - { - // config - var config = userDetails.UserCredentials.AuthProvider.Config; - TokenProvider = new GcpTokenProvider(config["cmd-path"]); - userCredentialsFound = true; - break; - } + throw new Exception("Please use the \"gke-gcloud-auth-plugin\" credential plugin instead. See https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke for further details"); case "oidc": { @@ -468,12 +463,7 @@ private void SetUserDetails(K8SConfiguration k8SConfig, Context activeContext) } } - public static string RenewAzureToken(string tenantId, string clientId, string apiServerId, string refresh) - { - throw new KubeConfigException("Refresh not supported."); - } - - public static Process CreateRunnableExternalProcess(ExternalExecution config) + public static Process CreateRunnableExternalProcess(ExternalExecution config, EventHandler captureStdError = null) { if (config == null) { @@ -514,8 +504,9 @@ public static Process CreateRunnableExternalProcess(ExternalExecution config) } process.StartInfo.RedirectStandardOutput = true; - process.StartInfo.RedirectStandardError = true; + process.StartInfo.RedirectStandardError = captureStdError != null; process.StartInfo.UseShellExecute = false; + process.StartInfo.CreateNoWindow = true; return process; } @@ -538,30 +529,48 @@ public static ExecCredentialResponse ExecuteExternalCommand(ExternalExecution co throw new ArgumentNullException(nameof(config)); } - var process = CreateRunnableExternalProcess(config); + var captureStdError = ExecStdError; + var process = CreateRunnableExternalProcess(config, captureStdError); try { process.Start(); + if (captureStdError != null) + { + process.ErrorDataReceived += captureStdError.Invoke; + process.BeginErrorReadLine(); + } } catch (Exception ex) { throw new KubeConfigException($"external exec failed due to: {ex.Message}"); } - var stdout = process.StandardOutput.ReadToEnd(); - var stderr = process.StandardError.ReadToEnd(); - if (string.IsNullOrWhiteSpace(stderr) == false) + try { - throw new KubeConfigException($"external exec failed due to: {stderr}"); - } + var output = new StringBuilder(); + process.OutputDataReceived += (_, args) => + { + if (args.Data != null) + { + output.Append(args.Data); + } + }; + process.BeginOutputReadLine(); - // Wait for a maximum of 5 seconds, if a response takes longer probably something went wrong... - process.WaitForExit(5); + if (!process.WaitForExit((int)ExecTimeout.TotalMilliseconds)) + { + throw new KubeConfigException("external exec failed due to timeout"); + } + + // Force flush the output buffer to avoid case of missing data + if (ExecTimeout != Timeout.InfiniteTimeSpan) + { + process.WaitForExit(); + } + + var responseObject = KubernetesJson.Deserialize(output.ToString()); - try - { - var responseObject = KubernetesJson.Deserialize(stdout); if (responseObject == null || responseObject.ApiVersion != config.ApiVersion) { throw new KubeConfigException( @@ -572,10 +581,8 @@ public static ExecCredentialResponse ExecuteExternalCommand(ExternalExecution co { return responseObject; } - else - { - throw new KubeConfigException($"external exec failed missing token or clientCertificateData field in plugin output"); - } + + throw new KubeConfigException($"external exec failed missing token or clientCertificateData field in plugin output"); } catch (JsonException ex) { diff --git a/src/KubernetesClient/KubernetesClientConfiguration.InCluster.cs b/src/KubernetesClient/KubernetesClientConfiguration.InCluster.cs index d799cf1f2..4846b7425 100644 --- a/src/KubernetesClient/KubernetesClientConfiguration.InCluster.cs +++ b/src/KubernetesClient/KubernetesClientConfiguration.InCluster.cs @@ -1,4 +1,3 @@ -using System.IO; using k8s.Authentication; using k8s.Exceptions; @@ -30,13 +29,13 @@ public static bool IsInCluster() } var tokenPath = Path.Combine(ServiceAccountPath, ServiceAccountTokenKeyFileName); - if (!FileUtils.FileSystem().File.Exists(tokenPath)) + if (!FileSystem.Current.Exists(tokenPath)) { return false; } var certPath = Path.Combine(ServiceAccountPath, ServiceAccountRootCAKeyFileName); - return FileUtils.FileSystem().File.Exists(certPath); + return FileSystem.Current.Exists(certPath); } public static KubernetesClientConfiguration InClusterConfig() @@ -68,9 +67,9 @@ public static KubernetesClientConfiguration InClusterConfig() }; var namespaceFile = Path.Combine(ServiceAccountPath, ServiceAccountNamespaceFileName); - if (FileUtils.FileSystem().File.Exists(namespaceFile)) + if (FileSystem.Current.Exists(namespaceFile)) { - result.Namespace = FileUtils.FileSystem().File.ReadAllText(namespaceFile); + result.Namespace = FileSystem.Current.ReadAllText(namespaceFile); } return result; diff --git a/src/KubernetesClient/KubernetesClientConfiguration.cs b/src/KubernetesClient/KubernetesClientConfiguration.cs index c0d171506..ac4a66719 100644 --- a/src/KubernetesClient/KubernetesClientConfiguration.cs +++ b/src/KubernetesClient/KubernetesClientConfiguration.cs @@ -1,6 +1,6 @@ +using k8s.Authentication; using System.Net.Http; using System.Security.Cryptography.X509Certificates; -using k8s.Autorest; namespace k8s { @@ -9,6 +9,8 @@ namespace k8s /// public partial class KubernetesClientConfiguration { + private JsonSerializerOptions jsonSerializerOptions; + /// /// Gets current namespace /// @@ -54,6 +56,11 @@ public partial class KubernetesClientConfiguration /// public bool SkipTlsVerify { get; set; } + /// + /// Option to override the TLS server name + /// + public string TlsServerName { get; set; } + /// /// Gets or sets the HTTP user agent. /// @@ -103,5 +110,43 @@ public partial class KubernetesClientConfiguration #else public Action FirstMessageHandlerSetup { get; set; } #endif + + /// + /// Do not use http2 even it is available + /// + public bool DisableHttp2 { get; set; } = false; + + /// + /// Options for the to override the default ones. + /// + public JsonSerializerOptions JsonSerializerOptions + { + get + { + // If not yet set, use defaults from KubernetesJson. + if (jsonSerializerOptions is null) + { + KubernetesJson.AddJsonOptions(options => + { + jsonSerializerOptions = new JsonSerializerOptions(options); + }); + } + + return jsonSerializerOptions; + } + + private set => jsonSerializerOptions = value; + } + + /// + public void AddJsonOptions(Action configure) + { + if (configure is null) + { + throw new ArgumentNullException(nameof(configure)); + } + + configure(JsonSerializerOptions); + } } } diff --git a/src/KubernetesClient/KubernetesException.cs b/src/KubernetesClient/KubernetesException.cs index 3dd4e7667..7d5ab6fb5 100644 --- a/src/KubernetesClient/KubernetesException.cs +++ b/src/KubernetesClient/KubernetesException.cs @@ -1,6 +1,3 @@ -using k8s.Models; -using System.Runtime.Serialization; - namespace k8s { /// @@ -73,22 +70,6 @@ public KubernetesException(string message, Exception innerException) { } - /// - /// Initializes a new instance of the class with serialized data. - /// - /// - /// The that holds the serialized - /// object data about the exception being thrown. - /// - /// - /// The that contains contextual information - /// about the source or destination. - /// - protected KubernetesException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - /// /// Gets, when this exception was raised because of a Kubernetes status message, the underlying /// Kubernetes status message. diff --git a/src/KubernetesClient/KubernetesJson.cs b/src/KubernetesClient/KubernetesJson.cs new file mode 100644 index 000000000..69ecdf43e --- /dev/null +++ b/src/KubernetesClient/KubernetesJson.cs @@ -0,0 +1,212 @@ +using System.Globalization; +using System.Text.Json.Nodes; +using System.Text.RegularExpressions; +using System.Xml; + +#if NET8_0_OR_GREATER +using System.Text.Json.Serialization.Metadata; +#endif + +namespace k8s +{ + public static class KubernetesJson + { + internal static readonly JsonSerializerOptions JsonSerializerOptions = new JsonSerializerOptions(); + + public sealed class Iso8601TimeSpanConverter : JsonConverter + { + public override TimeSpan Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + var str = reader.GetString(); + return XmlConvert.ToTimeSpan(str); + } + + public override void Write(Utf8JsonWriter writer, TimeSpan value, JsonSerializerOptions options) + { + var iso8601TimeSpanString = XmlConvert.ToString(value); // XmlConvert for TimeSpan uses ISO8601, so delegate serialization to it + writer.WriteStringValue(iso8601TimeSpanString); + } + } + + public sealed class KubernetesDateTimeOffsetConverter : JsonConverter + { + private const string RFC3339MicroFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.ffffffZ"; + private const string RFC3339NanoFormat = "yyyy-MM-dd'T'HH':'mm':'ss.fffffffZ"; + private const string RFC3339Format = "yyyy'-'MM'-'dd'T'HH':'mm':'ssZ"; + + public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + var str = reader.GetString(); + + if (DateTimeOffset.TryParseExact(str, new[] { RFC3339Format, RFC3339MicroFormat }, CultureInfo.InvariantCulture, DateTimeStyles.None, out var result)) + { + return result; + } + + // try RFC3339NanoLenient by trimming 1-9 digits to 7 digits + var originalstr = str; + str = Regex.Replace(str, @"\.\d+", m => (m.Value + "000000000").Substring(0, 7 + 1)); // 7 digits + 1 for the dot + if (DateTimeOffset.TryParseExact(str, new[] { RFC3339NanoFormat }, CultureInfo.InvariantCulture, DateTimeStyles.None, out result)) + { + return result; + } + + throw new FormatException($"Unable to parse {originalstr} as RFC3339 RFC3339Micro or RFC3339Nano"); + } + + + public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options) + { + // Output as RFC3339Micro + var date = value.ToUniversalTime(); + + var basePart = date.ToString("yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture); + var frac = date.ToString(".ffffff", CultureInfo.InvariantCulture) + .TrimEnd('0') + .TrimEnd('.'); + + writer.WriteStringValue(basePart + frac + "Z"); + } + } + + public sealed class KubernetesDateTimeConverter : JsonConverter + { + private static readonly JsonConverter UtcConverter = new KubernetesDateTimeOffsetConverter(); + public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + return UtcConverter.Read(ref reader, typeToConvert, options).UtcDateTime; + } + + public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options) + { + UtcConverter.Write(writer, value, options); + } + } + + static KubernetesJson() + { +#if K8S_AOT + // Uses Source Generated IJsonTypeInfoResolver + JsonSerializerOptions.TypeInfoResolver = SourceGenerationContext.Default; +#else +#if NET8_0_OR_GREATER + // Uses Source Generated IJsonTypeInfoResolver when available and falls back to reflection + JsonSerializerOptions.TypeInfoResolver = JsonTypeInfoResolver.Combine(SourceGenerationContext.Default, new DefaultJsonTypeInfoResolver()); +#endif + JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); +#endif + JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; + JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; + JsonSerializerOptions.Converters.Add(new Iso8601TimeSpanConverter()); + JsonSerializerOptions.Converters.Add(new KubernetesDateTimeConverter()); + JsonSerializerOptions.Converters.Add(new KubernetesDateTimeOffsetConverter()); + JsonSerializerOptions.Converters.Add(new V1Status.V1StatusObjectViewConverter()); + } + + /// + /// Configures for the . + /// To override existing converters, add them to the top of the list + /// e.g. as follows: options.Converters.Insert(index: 0, new JsonStringEnumConverter(JsonNamingPolicy.CamelCase)); + /// + /// An to configure the . + public static void AddJsonOptions(Action configure) + { + if (configure is null) + { + throw new ArgumentNullException(nameof(configure)); + } + + configure(JsonSerializerOptions); + } + + public static TValue Deserialize(string json, JsonSerializerOptions jsonSerializerOptions = null) + { +#if NET8_0_OR_GREATER + var info = (JsonTypeInfo)(jsonSerializerOptions ?? JsonSerializerOptions).GetTypeInfo(typeof(TValue)); + return JsonSerializer.Deserialize(json, info); +#else + return JsonSerializer.Deserialize(json, jsonSerializerOptions ?? JsonSerializerOptions); +#endif + } + + public static TValue Deserialize(Stream json, JsonSerializerOptions jsonSerializerOptions = null) + { +#if NET8_0_OR_GREATER + var info = (JsonTypeInfo)(jsonSerializerOptions ?? JsonSerializerOptions).GetTypeInfo(typeof(TValue)); + return JsonSerializer.Deserialize(json, info); +#else + return JsonSerializer.Deserialize(json, jsonSerializerOptions ?? JsonSerializerOptions); +#endif + } + + public static TValue Deserialize(JsonDocument json, JsonSerializerOptions jsonSerializerOptions = null) + { +#if NET8_0_OR_GREATER + var info = (JsonTypeInfo)(jsonSerializerOptions ?? JsonSerializerOptions).GetTypeInfo(typeof(TValue)); + return JsonSerializer.Deserialize(json, info); +#else + return JsonSerializer.Deserialize(json, jsonSerializerOptions ?? JsonSerializerOptions); +#endif + } + + public static TValue Deserialize(JsonElement json, JsonSerializerOptions jsonSerializerOptions = null) + { +#if NET8_0_OR_GREATER + var info = (JsonTypeInfo)(jsonSerializerOptions ?? JsonSerializerOptions).GetTypeInfo(typeof(TValue)); + return JsonSerializer.Deserialize(json, info); +#else + return JsonSerializer.Deserialize(json, jsonSerializerOptions ?? JsonSerializerOptions); +#endif + } + + public static TValue Deserialize(JsonNode json, JsonSerializerOptions jsonSerializerOptions = null) + { +#if NET8_0_OR_GREATER + var info = (JsonTypeInfo)(jsonSerializerOptions ?? JsonSerializerOptions).GetTypeInfo(typeof(TValue)); + return JsonSerializer.Deserialize(json, info); +#else + return JsonSerializer.Deserialize(json, jsonSerializerOptions ?? JsonSerializerOptions); +#endif + } + + public static string Serialize(object value, JsonSerializerOptions jsonSerializerOptions = null) + { +#if NET8_0_OR_GREATER + var info = (jsonSerializerOptions ?? JsonSerializerOptions).GetTypeInfo(value.GetType()); + return JsonSerializer.Serialize(value, info); +#else + return JsonSerializer.Serialize(value, jsonSerializerOptions ?? JsonSerializerOptions); +#endif + } + + public static string Serialize(JsonDocument value, JsonSerializerOptions jsonSerializerOptions = null) + { +#if NET8_0_OR_GREATER + var info = (jsonSerializerOptions ?? JsonSerializerOptions).GetTypeInfo(value.GetType()); + return JsonSerializer.Serialize(value, info); +#else + return JsonSerializer.Serialize(value, jsonSerializerOptions ?? JsonSerializerOptions); +#endif + } + + public static string Serialize(JsonElement value, JsonSerializerOptions jsonSerializerOptions = null) + { +#if NET8_0_OR_GREATER + var info = (jsonSerializerOptions ?? JsonSerializerOptions).GetTypeInfo(value.GetType()); + return JsonSerializer.Serialize(value, info); +#else + return JsonSerializer.Serialize(value, jsonSerializerOptions ?? JsonSerializerOptions); +#endif + } + + public static string Serialize(JsonNode value, JsonSerializerOptions jsonSerializerOptions = null) + { +#if NET8_0_OR_GREATER + var info = (jsonSerializerOptions ?? JsonSerializerOptions).GetTypeInfo(value.GetType()); + return JsonSerializer.Serialize(value, info); +#else + return JsonSerializer.Serialize(value, jsonSerializerOptions ?? JsonSerializerOptions); +#endif + } + } +} diff --git a/src/KubernetesClient/KubernetesMetricsExtensions.cs b/src/KubernetesClient/KubernetesMetricsExtensions.cs index a5dec8885..b676cd542 100644 --- a/src/KubernetesClient/KubernetesMetricsExtensions.cs +++ b/src/KubernetesClient/KubernetesMetricsExtensions.cs @@ -1,6 +1,3 @@ -using k8s.Models; -using System.Threading.Tasks; - namespace k8s { /// diff --git a/src/KubernetesClient.Models/KubernetesObject.cs b/src/KubernetesClient/KubernetesObject.cs similarity index 100% rename from src/KubernetesClient.Models/KubernetesObject.cs rename to src/KubernetesClient/KubernetesObject.cs diff --git a/src/KubernetesClient/KubernetesRequestDigest.cs b/src/KubernetesClient/KubernetesRequestDigest.cs index b6d669a7a..8024d9f34 100644 --- a/src/KubernetesClient/KubernetesRequestDigest.cs +++ b/src/KubernetesClient/KubernetesRequestDigest.cs @@ -8,7 +8,7 @@ namespace k8s { internal class KubernetesRequestDigest { - private static Regex resourcePattern = + private static readonly Regex ResourcePattern = new Regex(@"^/(api|apis)(/\S+)?/v\d\w*/\S+", RegexOptions.Compiled); public string Path { get; } @@ -94,13 +94,13 @@ public static KubernetesRequestDigest Parse(HttpRequestMessage request) private static KubernetesRequestDigest NonResource(string urlPath) { - KubernetesRequestDigest digest = new KubernetesRequestDigest(urlPath, true, "nonresource", "na", "na", "na"); + var digest = new KubernetesRequestDigest(urlPath, true, "nonresource", "na", "na", "na"); return digest; } public static bool IsResourceRequest(string urlPath) { - return resourcePattern.Matches(urlPath).Count > 0; + return ResourcePattern.Matches(urlPath).Count > 0; } private static bool HasWatchParameter(HttpRequestMessage request) diff --git a/src/KubernetesClient.Models/KubernetesYaml.cs b/src/KubernetesClient/KubernetesYaml.cs similarity index 68% rename from src/KubernetesClient.Models/KubernetesYaml.cs rename to src/KubernetesClient/KubernetesYaml.cs index 2f197415e..ef5384c72 100644 --- a/src/KubernetesClient.Models/KubernetesYaml.cs +++ b/src/KubernetesClient/KubernetesYaml.cs @@ -1,12 +1,9 @@ -using System.IO; using System.Reflection; using System.Text; -using System.Threading.Tasks; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; -using k8s.Models; namespace k8s { @@ -15,15 +12,29 @@ namespace k8s /// public static class KubernetesYaml { - private static readonly IDeserializer Deserializer = + private static readonly object DeserializerLockObject = new object(); + private static readonly object SerializerLockObject = new object(); + + private static DeserializerBuilder CommonDeserializerBuilder => new DeserializerBuilder() .WithNamingConvention(CamelCaseNamingConvention.Instance) .WithTypeConverter(new IntOrStringYamlConverter()) .WithTypeConverter(new ByteArrayStringYamlConverter()) .WithTypeConverter(new ResourceQuantityYamlConverter()) - .WithOverridesFromJsonPropertyAttributes() - .IgnoreUnmatchedProperties() - .Build(); + .WithTypeConverter(new KubernetesDateTimeYamlConverter()) + .WithTypeConverter(new KubernetesDateTimeOffsetYamlConverter()) + .WithAttemptingUnquotedStringTypeDeserialization() + .WithOverridesFromJsonPropertyAttributes(); + + private static readonly IDeserializer StrictDeserializer = + CommonDeserializerBuilder + .WithDuplicateKeyChecking() + .Build(); + private static readonly IDeserializer Deserializer = + CommonDeserializerBuilder + .IgnoreUnmatchedProperties() + .Build(); + private static IDeserializer GetDeserializer(bool strict) => strict ? StrictDeserializer : Deserializer; private static readonly IValueSerializer Serializer = new SerializerBuilder() @@ -32,7 +43,10 @@ public static class KubernetesYaml .WithTypeConverter(new IntOrStringYamlConverter()) .WithTypeConverter(new ByteArrayStringYamlConverter()) .WithTypeConverter(new ResourceQuantityYamlConverter()) + .WithTypeConverter(new KubernetesDateTimeYamlConverter()) + .WithTypeConverter(new KubernetesDateTimeOffsetYamlConverter()) .WithEventEmitter(e => new StringQuotingEmitter(e)) + .WithEventEmitter(e => new FloatEmitter(e)) .ConfigureDefaultValuesHandling(DefaultValuesHandling.OmitNull) .WithOverridesFromJsonPropertyAttributes() .BuildValueSerializer(); @@ -57,7 +71,7 @@ public bool Accepts(Type type) return type == typeof(byte[]); } - public object ReadYaml(IParser parser, Type type) + public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer) { if (parser?.Current is Scalar scalar) { @@ -68,7 +82,7 @@ public object ReadYaml(IParser parser, Type type) return null; } - return Encoding.UTF8.GetBytes(scalar.Value); + return Convert.FromBase64String(scalar.Value); } finally { @@ -79,10 +93,17 @@ public object ReadYaml(IParser parser, Type type) throw new InvalidOperationException(parser.Current?.ToString()); } - public void WriteYaml(IEmitter emitter, object value, Type type) + public void WriteYaml(IEmitter emitter, object value, Type type, ObjectSerializer serializer) { + if (value == null) + { + emitter.Emit(new Scalar(string.Empty)); + return; + } + var obj = (byte[])value; - emitter?.Emit(new Scalar(Encoding.UTF8.GetString(obj))); + var encoded = Convert.ToBase64String(obj); + emitter.Emit(new Scalar(encoded)); } } @@ -98,8 +119,9 @@ public void WriteYaml(IEmitter emitter, object value, Type type) /// A map from apiVersion/kind to Type. For example "v1/Pod" -> typeof(V1Pod). If null, a default mapping will /// be used. /// + /// true if a strict deserializer should be used (throwing exception on unknown properties), false otherwise /// collection of objects - public static async Task> LoadAllFromStreamAsync(Stream stream, IDictionary typeMap = null) + public static async Task> LoadAllFromStreamAsync(Stream stream, IDictionary typeMap = null, bool strict = false) { var reader = new StreamReader(stream); var content = await reader.ReadToEndAsync().ConfigureAwait(false); @@ -115,8 +137,9 @@ public static async Task> LoadAllFromStreamAsync(Stream stream, IDi /// A map from apiVersion/kind to Type. For example "v1/Pod" -> typeof(V1Pod). If null, a default mapping will /// be used. /// + /// true if a strict deserializer should be used (throwing exception on unknown properties), false otherwise /// collection of objects - public static async Task> LoadAllFromFileAsync(string fileName, IDictionary typeMap = null) + public static async Task> LoadAllFromFileAsync(string fileName, IDictionary typeMap = null, bool strict = false) { using (var fileStream = File.OpenRead(fileName)) { @@ -134,55 +157,62 @@ public static async Task> LoadAllFromFileAsync(string fileName, IDi /// A map from apiVersion/kind to Type. For example "v1/Pod" -> typeof(V1Pod). If null, a default mapping will /// be used. /// + /// true if a strict deserializer should be used (throwing exception on unknown properties), false otherwise /// collection of objects - public static List LoadAllFromString(string content, IDictionary typeMap = null) + public static List LoadAllFromString(string content, IDictionary typeMap = null, bool strict = false) { var mergedTypeMap = new Dictionary(ModelTypeMap); // merge in KVPs from typeMap, overriding any in ModelTypeMap typeMap?.ToList().ForEach(x => mergedTypeMap[x.Key] = x.Value); var types = new List(); - var parser = new Parser(new StringReader(content)); + var parser = new MergingParser(new Parser(new StringReader(content))); parser.Consume(); while (parser.Accept(out _)) { - var obj = Deserializer.Deserialize(parser); - types.Add(mergedTypeMap[obj.ApiVersion + "/" + obj.Kind]); + lock (DeserializerLockObject) + { + var dict = GetDeserializer(strict).Deserialize>(parser); + types.Add(mergedTypeMap[dict["apiVersion"] + "/" + dict["kind"]]); + } } - parser = new Parser(new StringReader(content)); + parser = new MergingParser(new Parser(new StringReader(content))); parser.Consume(); var ix = 0; var results = new List(); while (parser.Accept(out _)) { var objType = types[ix++]; - var obj = Deserializer.Deserialize(parser, objType); - results.Add(obj); + lock (DeserializerLockObject) + { + var obj = GetDeserializer(strict).Deserialize(parser, objType); + results.Add(obj); + } } return results; } - public static async Task LoadFromStreamAsync(Stream stream) + public static async Task LoadFromStreamAsync(Stream stream, bool strict = false) { var reader = new StreamReader(stream); var content = await reader.ReadToEndAsync().ConfigureAwait(false); - return Deserialize(content); + return Deserialize(content, strict); } - public static async Task LoadFromFileAsync(string file) + public static async Task LoadFromFileAsync(string file, bool strict = false) { using (var fs = File.OpenRead(file)) { - return await LoadFromStreamAsync(fs).ConfigureAwait(false); + return await LoadFromStreamAsync(fs, strict).ConfigureAwait(false); } } [Obsolete("use Deserialize")] - public static T LoadFromString(string content) + public static T LoadFromString(string content, bool strict = false) { - return Deserialize(content); + return Deserialize(content, strict); } [Obsolete("use Serialize")] @@ -191,14 +221,22 @@ public static string SaveToString(T value) return Serialize(value); } - public static TValue Deserialize(string yaml) + public static TValue Deserialize(string yaml, bool strict = false) { - return Deserializer.Deserialize(yaml); + using var reader = new StringReader(yaml); + lock (DeserializerLockObject) + { + return GetDeserializer(strict).Deserialize(new MergingParser(new Parser(reader))); + } } - public static TValue Deserialize(Stream yaml) + public static TValue Deserialize(Stream yaml, bool strict = false) { - return Deserializer.Deserialize(new StreamReader(yaml)); + using var reader = new StreamReader(yaml); + lock (DeserializerLockObject) + { + return GetDeserializer(strict).Deserialize(new MergingParser(new Parser(reader))); + } } public static string SerializeAll(IEnumerable values) @@ -219,7 +257,11 @@ public static string SerializeAll(IEnumerable values) if (value != null) { emitter.Emit(new DocumentStart()); - Serializer.SerializeValue(emitter, value, value.GetType()); + lock (SerializerLockObject) + { + Serializer.SerializeValue(emitter, value, value.GetType()); + } + emitter.Emit(new DocumentEnd(true)); } } @@ -240,7 +282,10 @@ public static string Serialize(object value) emitter.Emit(new StreamStart()); emitter.Emit(new DocumentStart()); - Serializer.SerializeValue(emitter, value, value.GetType()); + lock (SerializerLockObject) + { + Serializer.SerializeValue(emitter, value, value.GetType()); + } return stringBuilder.ToString(); } diff --git a/src/KubernetesClient/LeaderElection/ILock.cs b/src/KubernetesClient/LeaderElection/ILock.cs index 2fd5cdd47..a56e0fd38 100644 --- a/src/KubernetesClient/LeaderElection/ILock.cs +++ b/src/KubernetesClient/LeaderElection/ILock.cs @@ -1,6 +1,3 @@ -using System.Threading; -using System.Threading.Tasks; - namespace k8s.LeaderElection { /// diff --git a/src/KubernetesClient/LeaderElection/LeaderElectionRecord.cs b/src/KubernetesClient/LeaderElection/LeaderElectionRecord.cs index 1bdb54f15..98bae7dac 100644 --- a/src/KubernetesClient/LeaderElection/LeaderElectionRecord.cs +++ b/src/KubernetesClient/LeaderElection/LeaderElectionRecord.cs @@ -62,7 +62,7 @@ public override int GetHashCode() { unchecked { - var hashCode = (HolderIdentity != null ? HolderIdentity.GetHashCode() : 0); + var hashCode = HolderIdentity != null ? HolderIdentity.GetHashCode() : 0; hashCode = (hashCode * 397) ^ AcquireTime.GetHashCode(); hashCode = (hashCode * 397) ^ RenewTime.GetHashCode(); return hashCode; diff --git a/src/KubernetesClient/LeaderElection/LeaderElector.cs b/src/KubernetesClient/LeaderElection/LeaderElector.cs index 8d0291e40..e7d86f9af 100644 --- a/src/KubernetesClient/LeaderElection/LeaderElector.cs +++ b/src/KubernetesClient/LeaderElection/LeaderElector.cs @@ -1,7 +1,4 @@ using System.Net; -using System.Threading; -using System.Threading.Tasks; -using k8s.Autorest; namespace k8s.LeaderElection { @@ -28,6 +25,11 @@ public class LeaderElector : IDisposable /// public event Action OnNewLeader; + /// + /// OnError is called when there is an error trying to determine leadership. + /// + public event Action OnError; + private volatile LeaderElectionRecord observedRecord; private DateTimeOffset observedTime = DateTimeOffset.MinValue; private string reportedLeader; @@ -47,7 +49,13 @@ public string GetLeader() return observedRecord?.HolderIdentity; } - public async Task RunAsync(CancellationToken cancellationToken = default) + /// + /// Tries to acquire and hold leadership once via a Kubernetes Lease resource. + /// Will complete the returned Task and not retry to acquire leadership again after leadership is lost once. + /// + /// A token to cancel the operation. + /// A Task representing the asynchronous operation. + public async Task RunUntilLeadershipLostAsync(CancellationToken cancellationToken = default) { await AcquireAsync(cancellationToken).ConfigureAwait(false); @@ -69,8 +77,9 @@ public async Task RunAsync(CancellationToken cancellationToken = default) MaybeReportTransition(); } } - catch + catch (Exception e) { + OnError?.Invoke(e); // ignore return false; } @@ -104,6 +113,33 @@ public async Task RunAsync(CancellationToken cancellationToken = default) } } + /// + /// Tries to acquire leadership via a Kubernetes Lease resource. + /// Will retry to acquire leadership again after leadership was lost. + /// + /// A Task which completes only on cancellation + /// A token to cancel the operation. + public async Task RunAndTryToHoldLeadershipForeverAsync(CancellationToken cancellationToken = default) + { + while (!cancellationToken.IsCancellationRequested) + { + await RunUntilLeadershipLostAsync(cancellationToken).ConfigureAwait(false); + } + } + + /// + /// Tries to acquire leadership once via a Kubernetes Lease resource. + /// Will complete the returned Task and not retry to acquire leadership again after leadership is lost once. + /// + /// + /// A token to cancel the operation. + /// A Task representing the asynchronous operation. + [Obsolete("Replaced by RunUntilLeadershipLostAsync to encode behavior in method name.")] + public Task RunAsync(CancellationToken cancellationToken = default) + { + return RunUntilLeadershipLostAsync(cancellationToken); + } + private async Task TryAcquireOrRenew(CancellationToken cancellationToken) { var l = config.Lock; @@ -127,6 +163,7 @@ private async Task TryAcquireOrRenew(CancellationToken cancellationToken) { if (e.Response.StatusCode != HttpStatusCode.NotFound) { + OnError?.Invoke(e); return false; } } @@ -206,8 +243,11 @@ private async Task AcquireAsync(CancellationToken cancellationToken) // wait RetryPeriod since acq return immediately await Task.Delay(delay, cancellationToken).ConfigureAwait(false); } - - // else timeout + else + { + // else timeout + _ = acq.ContinueWith(t => OnError?.Invoke(t.Exception), TaskContinuationOptions.OnlyOnFaulted); + } } finally { diff --git a/src/KubernetesClient/LeaderElection/ResourceLock/ConfigMapLock.cs b/src/KubernetesClient/LeaderElection/ResourceLock/ConfigMapLock.cs index b5e7a2617..eef16edde 100644 --- a/src/KubernetesClient/LeaderElection/ResourceLock/ConfigMapLock.cs +++ b/src/KubernetesClient/LeaderElection/ResourceLock/ConfigMapLock.cs @@ -1,7 +1,3 @@ -using k8s.Models; -using System.Threading; -using System.Threading.Tasks; - namespace k8s.LeaderElection.ResourceLock { public class ConfigMapLock : MetaObjectAnnotationLock diff --git a/src/KubernetesClient/LeaderElection/ResourceLock/EndpointsLock.cs b/src/KubernetesClient/LeaderElection/ResourceLock/EndpointsLock.cs index 1ebf64fc4..23ebaab1f 100644 --- a/src/KubernetesClient/LeaderElection/ResourceLock/EndpointsLock.cs +++ b/src/KubernetesClient/LeaderElection/ResourceLock/EndpointsLock.cs @@ -1,7 +1,3 @@ -using k8s.Models; -using System.Threading; -using System.Threading.Tasks; - namespace k8s.LeaderElection.ResourceLock { public class EndpointsLock : MetaObjectAnnotationLock diff --git a/src/KubernetesClient/LeaderElection/ResourceLock/LeaseLock.cs b/src/KubernetesClient/LeaderElection/ResourceLock/LeaseLock.cs index 35befc037..38de063ce 100644 --- a/src/KubernetesClient/LeaderElection/ResourceLock/LeaseLock.cs +++ b/src/KubernetesClient/LeaderElection/ResourceLock/LeaseLock.cs @@ -1,7 +1,3 @@ -using k8s.Models; -using System.Threading; -using System.Threading.Tasks; - namespace k8s.LeaderElection.ResourceLock { public class LeaseLock : MetaObjectLock diff --git a/src/KubernetesClient/LeaderElection/ResourceLock/MetaObjectAnnotationLock.cs b/src/KubernetesClient/LeaderElection/ResourceLock/MetaObjectAnnotationLock.cs index b755bcc5d..42f948db8 100644 --- a/src/KubernetesClient/LeaderElection/ResourceLock/MetaObjectAnnotationLock.cs +++ b/src/KubernetesClient/LeaderElection/ResourceLock/MetaObjectAnnotationLock.cs @@ -1,6 +1,3 @@ -using k8s.Models; - - namespace k8s.LeaderElection.ResourceLock { public abstract class MetaObjectAnnotationLock : MetaObjectLock diff --git a/src/KubernetesClient/LeaderElection/ResourceLock/MetaObjectLock.cs b/src/KubernetesClient/LeaderElection/ResourceLock/MetaObjectLock.cs index 0e5e61fa1..e2540482f 100644 --- a/src/KubernetesClient/LeaderElection/ResourceLock/MetaObjectLock.cs +++ b/src/KubernetesClient/LeaderElection/ResourceLock/MetaObjectLock.cs @@ -1,20 +1,19 @@ -using System.Threading; -using System.Threading.Tasks; -using k8s.Models; -using k8s.Autorest; - - namespace k8s.LeaderElection.ResourceLock { public abstract class MetaObjectLock : ILock where T : class, IMetadata, new() { - private IKubernetes client; - private string ns; - private string name; - private string identity; + private readonly IKubernetes client; + private readonly string ns; + private readonly string name; + private readonly string identity; private T metaObjCache; + /// + /// OnHttpError is called when there is a http operation error. + /// + public event Action OnHttpError; + protected MetaObjectLock(IKubernetes client, string @namespace, string name, string identity) { this.client = client ?? throw new ArgumentNullException(nameof(client)); @@ -53,8 +52,9 @@ public async Task CreateAsync(LeaderElectionRecord record, CancellationTok Interlocked.Exchange(ref metaObjCache, createdObj); return true; } - catch (HttpOperationException) + catch (HttpOperationException e) { + OnHttpError?.Invoke(e); // ignore } @@ -85,8 +85,9 @@ public async Task UpdateAsync(LeaderElectionRecord record, CancellationTok Interlocked.Exchange(ref metaObjCache, replacedObj); return true; } - catch (HttpOperationException) + catch (HttpOperationException e) { + OnHttpError?.Invoke(e); // ignore } diff --git a/src/KubernetesClient/LeaderElection/ResourceLock/MultiLock.cs b/src/KubernetesClient/LeaderElection/ResourceLock/MultiLock.cs index 4ce667976..64256612e 100644 --- a/src/KubernetesClient/LeaderElection/ResourceLock/MultiLock.cs +++ b/src/KubernetesClient/LeaderElection/ResourceLock/MultiLock.cs @@ -1,12 +1,9 @@ -using System.Threading; -using System.Threading.Tasks; - namespace k8s.LeaderElection.ResourceLock { public class MultiLock : ILock { - private ILock primary; - private ILock secondary; + private readonly ILock primary; + private readonly ILock secondary; public MultiLock(ILock primary, ILock secondary) { diff --git a/src/KubernetesClient/LineSeparatedHttpContent.cs b/src/KubernetesClient/LineSeparatedHttpContent.cs index f26c04056..9206fe4ff 100644 --- a/src/KubernetesClient/LineSeparatedHttpContent.cs +++ b/src/KubernetesClient/LineSeparatedHttpContent.cs @@ -1,8 +1,5 @@ -using System.IO; using System.Net; using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; namespace k8s { diff --git a/src/KubernetesClient.Models/ContainerMetrics.cs b/src/KubernetesClient/Models/ContainerMetrics.cs similarity index 100% rename from src/KubernetesClient.Models/ContainerMetrics.cs rename to src/KubernetesClient/Models/ContainerMetrics.cs diff --git a/src/KubernetesClient.Models/GeneratedModelVersion.cs b/src/KubernetesClient/Models/GeneratedModelVersion.cs similarity index 100% rename from src/KubernetesClient.Models/GeneratedModelVersion.cs rename to src/KubernetesClient/Models/GeneratedModelVersion.cs diff --git a/src/KubernetesClient/Models/IItems.cs b/src/KubernetesClient/Models/IItems.cs new file mode 100644 index 000000000..b82c4c3de --- /dev/null +++ b/src/KubernetesClient/Models/IItems.cs @@ -0,0 +1,27 @@ +namespace k8s.Models; + +/// +/// Kubernetes object that exposes list of objects +/// +/// type of the objects +public interface IItems +{ + /// + /// Gets or sets list of objects. More info: + /// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md + /// + IList Items { get; set; } +} + +public static class ItemsExt +{ + public static IEnumerator GetEnumerator(this IItems items) + { + if (items is null) + { + throw new ArgumentNullException(nameof(items)); + } + + return items.Items.GetEnumerator(); + } +} diff --git a/src/KubernetesClient/Models/IMetadata.cs b/src/KubernetesClient/Models/IMetadata.cs new file mode 100644 index 000000000..4fa7f3292 --- /dev/null +++ b/src/KubernetesClient/Models/IMetadata.cs @@ -0,0 +1,15 @@ +namespace k8s.Models; + +/// +/// Kubernetes object that exposes metadata +/// +/// Type of metadata exposed. Usually this will be either +/// for lists or for objects +public interface IMetadata +{ + /// + /// Gets or sets standard object's metadata. More info: + /// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + /// + T Metadata { get; set; } +} diff --git a/src/KubernetesClient/Models/ISpec.cs b/src/KubernetesClient/Models/ISpec.cs new file mode 100644 index 000000000..d05d62fab --- /dev/null +++ b/src/KubernetesClient/Models/ISpec.cs @@ -0,0 +1,15 @@ +namespace k8s.Models; + +/// +/// Represents a Kubernetes object that has a spec +/// +/// type of Kubernetes object +public interface ISpec +{ + /// + /// Gets or sets specification of the desired behavior of the entity. More + /// info: + /// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status + /// + T Spec { get; set; } +} diff --git a/src/KubernetesClient.Models/IStatus.cs b/src/KubernetesClient/Models/IStatus.cs similarity index 96% rename from src/KubernetesClient.Models/IStatus.cs rename to src/KubernetesClient/Models/IStatus.cs index e60f59fec..75d796666 100644 --- a/src/KubernetesClient.Models/IStatus.cs +++ b/src/KubernetesClient/Models/IStatus.cs @@ -1,4 +1,4 @@ -namespace k8s +namespace k8s.Models { /// /// Kubernetes object that exposes status diff --git a/src/KubernetesClient/Models/IntOrString.cs b/src/KubernetesClient/Models/IntOrString.cs new file mode 100644 index 000000000..65e9cd486 --- /dev/null +++ b/src/KubernetesClient/Models/IntOrString.cs @@ -0,0 +1,38 @@ +namespace k8s.Models +{ + [JsonConverter(typeof(IntOrStringJsonConverter))] + public class IntOrString + { + public string Value { get; private init; } + + public static implicit operator IntOrString(int v) + { + return Convert.ToString(v); + } + + public static implicit operator IntOrString(long v) + { + return Convert.ToString(v); + } + + public static implicit operator string(IntOrString v) + { + return v?.Value; + } + + public static implicit operator IntOrString(string v) + { + return new IntOrString { Value = v }; + } + + public override string ToString() + { + return Value; + } + + public int ToInt() + { + return int.Parse(Value); + } + } +} diff --git a/src/KubernetesClient.Models/IntOrStringJsonConverter.cs b/src/KubernetesClient/Models/IntOrStringJsonConverter.cs similarity index 73% rename from src/KubernetesClient.Models/IntOrStringJsonConverter.cs rename to src/KubernetesClient/Models/IntOrStringJsonConverter.cs index 9b665a30c..c7cbe273a 100644 --- a/src/KubernetesClient.Models/IntOrStringJsonConverter.cs +++ b/src/KubernetesClient/Models/IntOrStringJsonConverter.cs @@ -1,8 +1,8 @@ namespace k8s.Models { - internal sealed class IntOrStringJsonConverter : JsonConverter + internal sealed class IntOrStringJsonConverter : JsonConverter { - public override IntstrIntOrString Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override IntOrString Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { switch (reader.TokenType) { @@ -17,14 +17,14 @@ public override IntstrIntOrString Read(ref Utf8JsonReader reader, Type typeToCon throw new NotSupportedException(); } - public override void Write(Utf8JsonWriter writer, IntstrIntOrString value, JsonSerializerOptions options) + public override void Write(Utf8JsonWriter writer, IntOrString value, JsonSerializerOptions options) { if (writer == null) { throw new ArgumentNullException(nameof(writer)); } - var s = value?.Value; + var s = value.Value; if (long.TryParse(s, out var intv)) { diff --git a/src/KubernetesClient.Models/IntOrStringYamlConverter.cs b/src/KubernetesClient/Models/IntOrStringYamlConverter.cs similarity index 76% rename from src/KubernetesClient.Models/IntOrStringYamlConverter.cs rename to src/KubernetesClient/Models/IntOrStringYamlConverter.cs index 125ea5f93..cfaa42205 100644 --- a/src/KubernetesClient.Models/IntOrStringYamlConverter.cs +++ b/src/KubernetesClient/Models/IntOrStringYamlConverter.cs @@ -7,10 +7,10 @@ public class IntOrStringYamlConverter : IYamlTypeConverter { public bool Accepts(Type type) { - return type == typeof(IntstrIntOrString); + return type == typeof(IntOrString); } - public object ReadYaml(IParser parser, Type type) + public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer) { if (parser?.Current is YamlDotNet.Core.Events.Scalar scalar) { @@ -21,7 +21,7 @@ public object ReadYaml(IParser parser, Type type) return null; } - return new IntstrIntOrString(scalar?.Value); + return scalar?.Value; } finally { @@ -32,9 +32,9 @@ public object ReadYaml(IParser parser, Type type) throw new InvalidOperationException(parser?.Current?.ToString()); } - public void WriteYaml(IEmitter emitter, object value, Type type) + public void WriteYaml(IEmitter emitter, object value, Type type, ObjectSerializer serializer) { - var obj = (IntstrIntOrString)value; + var obj = (IntOrString)value; emitter?.Emit(new YamlDotNet.Core.Events.Scalar(obj?.Value)); } } diff --git a/src/KubernetesClient/Models/KubernetesDateTimeOffsetYamlConverter.cs b/src/KubernetesClient/Models/KubernetesDateTimeOffsetYamlConverter.cs new file mode 100644 index 000000000..5eb4153eb --- /dev/null +++ b/src/KubernetesClient/Models/KubernetesDateTimeOffsetYamlConverter.cs @@ -0,0 +1,64 @@ +using System.Globalization; +using System.Text.RegularExpressions; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; +using YamlDotNet.Serialization; + +namespace k8s.Models; + +public sealed class KubernetesDateTimeOffsetYamlConverter : IYamlTypeConverter +{ + private const string RFC3339MicroFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.ffffff'Z'"; + private const string RFC3339NanoFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffff'Z'"; + private const string RFC3339Format = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"; + + public bool Accepts(Type type) => type == typeof(DateTimeOffset); + + public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer) + { + if (parser?.Current is Scalar scalar) + { + try + { + if (string.IsNullOrEmpty(scalar.Value)) + { + return null; + } + + var str = scalar.Value; + + if (DateTimeOffset.TryParseExact(str, new[] { RFC3339Format, RFC3339MicroFormat }, CultureInfo.InvariantCulture, DateTimeStyles.None, out var result)) + { + return result; + } + + // try RFC3339NanoLenient by trimming 1-9 digits to 7 digits + var originalstr = str; + str = Regex.Replace(str, @"\.\d+", m => (m.Value + "000000000").Substring(0, 7 + 1)); // 7 digits + 1 for the dot + if (DateTimeOffset.TryParseExact(str, new[] { RFC3339NanoFormat }, CultureInfo.InvariantCulture, DateTimeStyles.None, out result)) + { + return result; + } + } + finally + { + parser.MoveNext(); + } + } + + throw new InvalidOperationException($"Unable to parse '{parser.Current?.ToString()}' as RFC3339, RFC3339Micro, or RFC3339Nano"); + } + + public void WriteYaml(IEmitter emitter, object value, Type type, ObjectSerializer serializer) + { + // Output as RFC3339Micro + var date = ((DateTimeOffset)value).ToUniversalTime(); + + var basePart = date.ToString("yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture); + var frac = date.ToString(".ffffff", CultureInfo.InvariantCulture) + .TrimEnd('0') + .TrimEnd('.'); + + emitter.Emit(new Scalar(AnchorName.Empty, TagName.Empty, basePart + frac + "Z", ScalarStyle.DoubleQuoted, true, false)); + } +} diff --git a/src/KubernetesClient/Models/KubernetesDateTimeYamlConverter.cs b/src/KubernetesClient/Models/KubernetesDateTimeYamlConverter.cs new file mode 100644 index 000000000..d6095983d --- /dev/null +++ b/src/KubernetesClient/Models/KubernetesDateTimeYamlConverter.cs @@ -0,0 +1,23 @@ +using YamlDotNet.Core; +using YamlDotNet.Serialization; + +namespace k8s.Models; + +public sealed class KubernetesDateTimeYamlConverter : IYamlTypeConverter +{ + private static readonly KubernetesDateTimeOffsetYamlConverter OffsetConverter = new(); + + public bool Accepts(Type type) => type == typeof(DateTime); + + public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer) + { + var dto = (DateTimeOffset)OffsetConverter.ReadYaml(parser, typeof(DateTimeOffset), rootDeserializer); + return dto.DateTime; + } + + public void WriteYaml(IEmitter emitter, object value, Type type, ObjectSerializer serializer) + { + var date = new DateTimeOffset((DateTime)value); + OffsetConverter.WriteYaml(emitter, date, typeof(DateTimeOffset), serializer); + } +} diff --git a/src/KubernetesClient.Models/KubernetesEntityAttribute.cs b/src/KubernetesClient/Models/KubernetesEntityAttribute.cs similarity index 100% rename from src/KubernetesClient.Models/KubernetesEntityAttribute.cs rename to src/KubernetesClient/Models/KubernetesEntityAttribute.cs diff --git a/src/KubernetesClient.Models/KubernetesList.cs b/src/KubernetesClient/Models/KubernetesList.cs similarity index 74% rename from src/KubernetesClient.Models/KubernetesList.cs rename to src/KubernetesClient/Models/KubernetesList.cs index e8167fd75..069c410b2 100644 --- a/src/KubernetesClient.Models/KubernetesList.cs +++ b/src/KubernetesClient/Models/KubernetesList.cs @@ -40,27 +40,5 @@ public KubernetesList(IList items, string apiVersion = default, string kind = /// [JsonPropertyName("metadata")] public V1ListMeta Metadata { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public void Validate() - { - if (Items == null) - { - throw new ArgumentNullException("Items"); - } - - if (Items != null) - { - foreach (var element in Items.OfType()) - { - element.Validate(); - } - } - } } } diff --git a/src/KubernetesClient.Models/ModelExtensions.cs b/src/KubernetesClient/Models/ModelExtensions.cs similarity index 98% rename from src/KubernetesClient.Models/ModelExtensions.cs rename to src/KubernetesClient/Models/ModelExtensions.cs index 0f4903b93..f2c6f6045 100644 --- a/src/KubernetesClient.Models/ModelExtensions.cs +++ b/src/KubernetesClient/Models/ModelExtensions.cs @@ -208,7 +208,7 @@ public static int FindOwnerReference(this IMetadata obj, IKubernet /// reference could be found. /// /// the object meta - /// a to test owner reference + /// a to test owner reference /// the index of the that matches the given object, or -1 if no such /// reference could be found. public static int FindOwnerReference(this IMetadata obj, Predicate predicate) @@ -300,7 +300,7 @@ public static V1OwnerReference GetOwnerReference( /// Gets the that matches the given predicate, or null if no matching reference exists. /// the object meta - /// a to test owner reference + /// a to test owner reference /// the that matches the given object, or null if no matching reference exists. public static V1OwnerReference GetOwnerReference( this IMetadata obj, @@ -400,7 +400,7 @@ public static V1OwnerReference RemoveOwnerReference( /// any were removed. /// /// the object meta - /// a to test owner reference + /// a to test owner reference /// true if any were removed public static bool RemoveOwnerReferences( this IMetadata obj, diff --git a/src/KubernetesClient.Models/NodeMetrics.cs b/src/KubernetesClient/Models/NodeMetrics.cs similarity index 100% rename from src/KubernetesClient.Models/NodeMetrics.cs rename to src/KubernetesClient/Models/NodeMetrics.cs diff --git a/src/KubernetesClient.Models/NodeMetricsList.cs b/src/KubernetesClient/Models/NodeMetricsList.cs similarity index 100% rename from src/KubernetesClient.Models/NodeMetricsList.cs rename to src/KubernetesClient/Models/NodeMetricsList.cs diff --git a/src/KubernetesClient.Models/PodMetrics.cs b/src/KubernetesClient/Models/PodMetrics.cs similarity index 100% rename from src/KubernetesClient.Models/PodMetrics.cs rename to src/KubernetesClient/Models/PodMetrics.cs diff --git a/src/KubernetesClient.Models/PodMetricsList.cs b/src/KubernetesClient/Models/PodMetricsList.cs similarity index 100% rename from src/KubernetesClient.Models/PodMetricsList.cs rename to src/KubernetesClient/Models/PodMetricsList.cs diff --git a/src/KubernetesClient.Models/ResourceQuantity.cs b/src/KubernetesClient/Models/ResourceQuantity.cs similarity index 93% rename from src/KubernetesClient.Models/ResourceQuantity.cs rename to src/KubernetesClient/Models/ResourceQuantity.cs index 41af52944..eee89c678 100644 --- a/src/KubernetesClient.Models/ResourceQuantity.cs +++ b/src/KubernetesClient/Models/ResourceQuantity.cs @@ -1,6 +1,6 @@ +using Fractions; using System.Globalization; using System.Numerics; -using Fractions; namespace k8s.Models { @@ -54,7 +54,7 @@ namespace k8s.Models /// cause implementors to also use a fixed point implementation. /// [JsonConverter(typeof(ResourceQuantityJsonConverter))] - public partial class ResourceQuantity + public class ResourceQuantity { public enum SuffixFormat { @@ -97,39 +97,6 @@ public override string ToString() return CanonicalizeString(); } - protected bool Equals(ResourceQuantity other) - { - return Format == other?.Format && _unitlessValue.Equals(other._unitlessValue); - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - if (obj.GetType() != GetType()) - { - return false; - } - - return Equals((ResourceQuantity)obj); - } - - public override int GetHashCode() - { - unchecked - { - return ((int)Format * 397) ^ _unitlessValue.GetHashCode(); - } - } - // // CanonicalizeString = go version CanonicalizeBytes // CanonicalizeBytes returns the canonical form of q and its suffix (see comment on Quantity). @@ -157,10 +124,9 @@ public string CanonicalizeString(SuffixFormat suffixFormat) return Suffixer.AppendMaxSuffix(_unitlessValue, suffixFormat); } - // ctor - partial void CustomInit() + public ResourceQuantity(string v) { - if (Value == null) + if (v == null) { // No value has been defined, initialize to 0. _unitlessValue = new Fraction(0); @@ -168,7 +134,7 @@ partial void CustomInit() return; } - var value = Value.Trim(); + var value = v.Trim(); var si = value.IndexOfAny(SuffixChars); if (si == -1) @@ -188,6 +154,11 @@ partial void CustomInit() } } + public static implicit operator ResourceQuantity(string v) + { + return new ResourceQuantity(v); + } + private static bool HasMantissa(Fraction value) { if (value.IsZero) @@ -200,7 +171,7 @@ private static bool HasMantissa(Fraction value) public static implicit operator decimal(ResourceQuantity v) { - return v?.ToDecimal() ?? 0; + return v.ToDecimal(); } public static implicit operator ResourceQuantity(decimal v) @@ -208,6 +179,46 @@ public static implicit operator ResourceQuantity(decimal v) return new ResourceQuantity(v, 0, SuffixFormat.DecimalExponent); } + public bool Equals(ResourceQuantity other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return _unitlessValue.Equals(other._unitlessValue); + } + + public override bool Equals(object obj) + { + return Equals(obj as ResourceQuantity); + } + + public override int GetHashCode() + { + return _unitlessValue.GetHashCode(); + } + + public static bool operator ==(ResourceQuantity left, ResourceQuantity right) + { + if (left is null) + { + return right is null; + } + + return left.Equals(right); + } + + public static bool operator !=(ResourceQuantity left, ResourceQuantity right) + { + return !(left == right); + } + private sealed class Suffixer { private static readonly IReadOnlyDictionary BinSuffixes = diff --git a/src/KubernetesClient/Models/ResourceQuantityJsonConverter.cs b/src/KubernetesClient/Models/ResourceQuantityJsonConverter.cs new file mode 100644 index 000000000..a99eb334b --- /dev/null +++ b/src/KubernetesClient/Models/ResourceQuantityJsonConverter.cs @@ -0,0 +1,34 @@ +namespace k8s.Models +{ + internal sealed class ResourceQuantityJsonConverter : JsonConverter + { + // https://github.com/kubernetes/apimachinery/blob/4b14f804a0babdcc58e695d72f77ad29f536511e/pkg/api/resource/quantity.go#L683 + public override ResourceQuantity Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + switch (reader.TokenType) + { + case JsonTokenType.Null: + return null; + case JsonTokenType.Number: + if (reader.TryGetDouble(out var val)) + { + return Convert.ToString(val); + } + + return reader.GetDecimal(); + default: + return reader.GetString(); + } + } + + public override void Write(Utf8JsonWriter writer, ResourceQuantity value, JsonSerializerOptions options) + { + if (writer == null) + { + throw new ArgumentNullException(nameof(writer)); + } + + writer.WriteStringValue(value.ToString()); + } + } +} diff --git a/src/KubernetesClient.Models/ResourceQuantityYamlConverter.cs b/src/KubernetesClient/Models/ResourceQuantityYamlConverter.cs similarity index 84% rename from src/KubernetesClient.Models/ResourceQuantityYamlConverter.cs rename to src/KubernetesClient/Models/ResourceQuantityYamlConverter.cs index ef274bf81..1006a3cd7 100644 --- a/src/KubernetesClient.Models/ResourceQuantityYamlConverter.cs +++ b/src/KubernetesClient/Models/ResourceQuantityYamlConverter.cs @@ -10,7 +10,7 @@ public bool Accepts(Type type) return type == typeof(ResourceQuantity); } - public object ReadYaml(IParser parser, Type type) + public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer) { if (parser?.Current is YamlDotNet.Core.Events.Scalar scalar) { @@ -21,7 +21,7 @@ public object ReadYaml(IParser parser, Type type) return null; } - return new ResourceQuantity(scalar?.Value); + return scalar?.Value; } finally { @@ -32,8 +32,7 @@ public object ReadYaml(IParser parser, Type type) throw new InvalidOperationException(parser?.Current?.ToString()); } - - public void WriteYaml(IEmitter emitter, object value, Type type) + public void WriteYaml(IEmitter emitter, object value, Type type, ObjectSerializer serializer) { var obj = (ResourceQuantity)value; emitter?.Emit(new YamlDotNet.Core.Events.Scalar(obj?.ToString())); diff --git a/src/KubernetesClient.Models/V1Patch.cs b/src/KubernetesClient/Models/V1Patch.cs similarity index 75% rename from src/KubernetesClient.Models/V1Patch.cs rename to src/KubernetesClient/Models/V1Patch.cs index 4f8f44c50..5838e4b05 100644 --- a/src/KubernetesClient.Models/V1Patch.cs +++ b/src/KubernetesClient/Models/V1Patch.cs @@ -1,7 +1,7 @@ namespace k8s.Models { [JsonConverter(typeof(V1PatchJsonConverter))] - public partial class V1Patch + public record V1Patch { public enum PatchType { @@ -31,26 +31,21 @@ public enum PatchType ApplyPatch, } + [JsonPropertyName("content")] + [JsonInclude] + public object Content { get; private set; } + public PatchType Type { get; private set; } public V1Patch(object body, PatchType type) { - Content = body; - Type = type; - CustomInit(); - } - - partial void CustomInit() - { - if (Content == null) + if (type == PatchType.Unknown) { - throw new ArgumentNullException(nameof(Content), "object must be set"); + throw new ArgumentException("patch type must be set", nameof(type)); } - if (Type == PatchType.Unknown) - { - throw new ArgumentException("patch type must be set", nameof(Type)); - } + Content = body ?? throw new ArgumentNullException(nameof(body), "object must be set"); + Type = type; } } } diff --git a/src/KubernetesClient.Models/V1PatchJsonConverter.cs b/src/KubernetesClient/Models/V1PatchJsonConverter.cs similarity index 100% rename from src/KubernetesClient.Models/V1PatchJsonConverter.cs rename to src/KubernetesClient/Models/V1PatchJsonConverter.cs diff --git a/src/KubernetesClient.Models/V1PodTemplateSpec.cs b/src/KubernetesClient/Models/V1PodTemplateSpec.cs similarity index 72% rename from src/KubernetesClient.Models/V1PodTemplateSpec.cs rename to src/KubernetesClient/Models/V1PodTemplateSpec.cs index 0462b5373..4efa3cdbb 100644 --- a/src/KubernetesClient.Models/V1PodTemplateSpec.cs +++ b/src/KubernetesClient/Models/V1PodTemplateSpec.cs @@ -4,7 +4,7 @@ namespace k8s.Models /// Partial implementation of the IMetadata interface /// to open this class up to ModelExtensions methods /// - public partial class V1PodTemplateSpec : IMetadata + public partial record V1PodTemplateSpec : IMetadata { } } diff --git a/src/KubernetesClient.Models/V1Status.ObjectView.cs b/src/KubernetesClient/Models/V1Status.ObjectView.cs similarity index 57% rename from src/KubernetesClient.Models/V1Status.ObjectView.cs rename to src/KubernetesClient/Models/V1Status.ObjectView.cs index 6f5a1ae85..710657847 100644 --- a/src/KubernetesClient.Models/V1Status.ObjectView.cs +++ b/src/KubernetesClient/Models/V1Status.ObjectView.cs @@ -1,23 +1,28 @@ namespace k8s.Models { - public partial class V1Status + public partial record V1Status { - internal sealed class V1StatusObjectViewConverter : JsonConverter + public sealed class V1StatusObjectViewConverter : JsonConverter { public override V1Status Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - var obj = JsonElement.ParseValue(ref reader); + using var doc = JsonDocument.ParseValue(ref reader); + var ele = doc.RootElement.Clone(); try { - return obj.Deserialize(); +#if NET8_0_OR_GREATER + return JsonSerializer.Deserialize(ele, StatusSourceGenerationContext.Default.V1Status); +#else + return ele.Deserialize(); +#endif } catch (JsonException) { // should be an object } - return new V1Status { _original = obj, HasObject = true }; + return new V1Status { _original = ele, HasObject = true }; } public override void Write(Utf8JsonWriter writer, V1Status value, JsonSerializerOptions options) @@ -32,7 +37,11 @@ public override void Write(Utf8JsonWriter writer, V1Status value, JsonSerializer public T ObjectView() { +#if NET8_0_OR_GREATER + return KubernetesJson.Deserialize(_original); +#else return _original.Deserialize(); +#endif } } } diff --git a/src/KubernetesClient.Models/V1Status.cs b/src/KubernetesClient/Models/V1Status.cs similarity index 95% rename from src/KubernetesClient.Models/V1Status.cs rename to src/KubernetesClient/Models/V1Status.cs index 87e4be055..d69116d2e 100644 --- a/src/KubernetesClient.Models/V1Status.cs +++ b/src/KubernetesClient/Models/V1Status.cs @@ -2,7 +2,7 @@ namespace k8s.Models { - public partial class V1Status + public partial record V1Status { /// Converts a object into a short description of the status. /// string description of the status diff --git a/src/KubernetesClient/MuxedStream.cs b/src/KubernetesClient/MuxedStream.cs index ed73d1743..17edc1f0e 100644 --- a/src/KubernetesClient/MuxedStream.cs +++ b/src/KubernetesClient/MuxedStream.cs @@ -1,5 +1,3 @@ -using System.IO; - namespace k8s { /// @@ -7,9 +5,9 @@ namespace k8s /// public class MuxedStream : Stream { - private ByteBuffer inputBuffer; - private byte? outputIndex; - private StreamDemuxer muxer; + private readonly ByteBuffer inputBuffer; + private readonly byte? outputIndex; + private readonly StreamDemuxer muxer; /// /// Initializes a new instance of the class. diff --git a/src/KubernetesClient/PrometheusHandler.cs b/src/KubernetesClient/PrometheusHandler.cs index 05cf14c91..7b7bd5461 100644 --- a/src/KubernetesClient/PrometheusHandler.cs +++ b/src/KubernetesClient/PrometheusHandler.cs @@ -1,57 +1,79 @@ -using Prometheus; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; - -namespace k8s.Monitoring -{ - public class PrometheusHandler : DelegatingHandler - { - private const string PREFIX = "k8s_dotnet"; - private readonly Counter requests = Metrics.CreateCounter( - $"{PREFIX}_request_total", "Number of requests sent by this client", - new CounterConfiguration - { - LabelNames = new[] { "method" }, - }); - - private readonly Histogram requestLatency = Metrics.CreateHistogram( - $"{PREFIX}_request_latency_seconds", "Latency of requests sent by this client", - new HistogramConfiguration - { - LabelNames = new[] { "verb", "group", "version", "kind" }, - }); - - private readonly Counter responseCodes = Metrics.CreateCounter( - $"{PREFIX}_response_code_total", "Number of response codes received by the client", - new CounterConfiguration - { - LabelNames = new[] { "method", "code" }, - }); - - private readonly Gauge activeRequests = Metrics.CreateGauge( - $"{PREFIX}_active_requests", "Number of requests currently in progress", - new GaugeConfiguration - { - LabelNames = new[] { "method" }, - }); - - protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) - { - if (request == null) - { - throw new ArgumentNullException(nameof(request)); - } - - var digest = KubernetesRequestDigest.Parse(request); - requests.WithLabels(digest.Verb).Inc(); - using (activeRequests.WithLabels(digest.Verb).TrackInProgress()) - using (requestLatency.WithLabels(digest.Verb, digest.ApiGroup, digest.ApiVersion, digest.Kind).NewTimer()) - { - var resp = await base.SendAsync(request, cancellationToken).ConfigureAwait(false); - responseCodes.WithLabels(request.Method.ToString(), ((int)resp.StatusCode).ToString()).Inc(); - return resp; - } - } - } -} +using System.Diagnostics; +using System.Diagnostics.Metrics; +using System.Net.Http; + +namespace k8s +{ + /// + /// Implements legacy Prometheus metrics + /// + /// Provided for compatibility for existing usages of PrometheusHandler. It is recommended + /// to transition to using OpenTelemetry and the default HttpClient metrics. + /// + /// Note that the tags/labels are not appropriately named for some metrics. This + /// incorrect naming is retained to maintain compatibility and won't be fixed on this implementation. + /// Use OpenTelemetry and the standard HttpClient metrics instead. + public class PrometheusHandler : DelegatingHandler + { + private const string Prefix = "k8s_dotnet"; + private static readonly Meter Meter = new Meter("k8s.dotnet"); + + private static readonly Counter RequestsSent = Meter.CreateCounter( + $"{Prefix}_request_total", + description: "Number of requests sent by this client"); + + private static readonly Histogram RequestLatency = Meter.CreateHistogram( + $"{Prefix}_request_latency_seconds", unit: "milliseconds", + description: "Latency of requests sent by this client"); + + private static readonly Counter ResponseCodes = Meter.CreateCounter( + $"{Prefix}_response_code_total", + description: "Number of response codes received by the client"); + + private static readonly UpDownCounter ActiveRequests = + Meter.CreateUpDownCounter( + $"{Prefix}_active_requests", + description: "Number of requests currently in progress"); + + /// + protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + if (request == null) + { + throw new ArgumentNullException(nameof(request)); + } + + var digest = KubernetesRequestDigest.Parse(request); + var timer = Stopwatch.StartNew(); + // Note that this is a tag called "method" but the value is the Verb. + // This is incorrect, but existing behavior. + var methodWithVerbValue = new KeyValuePair("method", digest.Verb); + try + { + ActiveRequests.Add(1, methodWithVerbValue); + RequestsSent.Add(1, methodWithVerbValue); + + var resp = await base.SendAsync(request, cancellationToken).ConfigureAwait(false); + ResponseCodes.Add( + 1, + new KeyValuePair("method", request.Method.ToString()), + new KeyValuePair("code", (int)resp.StatusCode)); + return resp; + } + finally + { + timer.Stop(); + ActiveRequests.Add(-1, methodWithVerbValue); + var tags = new TagList + { + { "verb", digest.Verb }, + { "group", digest.ApiGroup }, + { "version", digest.ApiVersion }, + { "kind", digest.Kind }, + } + ; + RequestLatency.Record(timer.Elapsed.TotalMilliseconds, tags); + } + } + } +} diff --git a/src/KubernetesClient/SourceGenerationContext.cs b/src/KubernetesClient/SourceGenerationContext.cs new file mode 100644 index 000000000..22cc9fa00 --- /dev/null +++ b/src/KubernetesClient/SourceGenerationContext.cs @@ -0,0 +1,28 @@ +using static k8s.KubernetesJson; +using static k8s.Models.V1Status; + +namespace k8s; + +[JsonSourceGenerationOptions( + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, + UseStringEnumConverter = true, + Converters = new[] { typeof(Iso8601TimeSpanConverter), typeof(KubernetesDateTimeConverter), typeof(KubernetesDateTimeOffsetConverter), typeof(V1StatusObjectViewConverter) }) + ] +public partial class SourceGenerationContext : JsonSerializerContext +{ +} + +/// +/// Used by V1Status in order to avoid the recursive loop as SourceGenerationContext contains V1StatusObjectViewConverter +/// +[JsonSerializable(typeof(V1Status))] +[JsonSourceGenerationOptions( + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, + UseStringEnumConverter = true, + Converters = new[] { typeof(Iso8601TimeSpanConverter), typeof(KubernetesDateTimeConverter), typeof(KubernetesDateTimeOffsetConverter) }) + ] +public partial class StatusSourceGenerationContext : JsonSerializerContext +{ +} diff --git a/src/KubernetesClient/StreamDemuxer.cs b/src/KubernetesClient/StreamDemuxer.cs index 1d4ac7404..30263b9eb 100644 --- a/src/KubernetesClient/StreamDemuxer.cs +++ b/src/KubernetesClient/StreamDemuxer.cs @@ -1,22 +1,19 @@ using System.Buffers; using System.Diagnostics; -using System.IO; using System.Net.WebSockets; -using System.Threading; -using System.Threading.Tasks; namespace k8s { /// /// /// The allows you to interact with processes running in a container in a Kubernetes pod. You can start an exec or attach command - /// by calling - /// or . These methods - /// will return you a connection. + /// by calling + /// or . These methods + /// will return you a connection. /// /// - /// Kubernetes 'multiplexes' multiple channels over this connection, such as standard input, standard output and standard error. The - /// allows you to extract individual s from this class. You can then use these streams to send/receive data from that process. + /// Kubernetes 'multiplexes' multiple channels over this connection, such as standard input, standard output and standard error. The + /// allows you to extract individual s from this . You can then use these streams to send/receive data from that process. /// /// public class StreamDemuxer : IStreamDemuxer diff --git a/src/KubernetesClient.Models/StringQuotingEmitter.cs b/src/KubernetesClient/StringQuotingEmitter.cs similarity index 100% rename from src/KubernetesClient.Models/StringQuotingEmitter.cs rename to src/KubernetesClient/StringQuotingEmitter.cs diff --git a/src/KubernetesClient/Util/Common/BadNotificationException.cs b/src/KubernetesClient/Util/Common/BadNotificationException.cs deleted file mode 100644 index aa5a5b58e..000000000 --- a/src/KubernetesClient/Util/Common/BadNotificationException.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace k8s.Util.Common -{ - public class BadNotificationException : Exception - { - public BadNotificationException() - { - } - - public BadNotificationException(string message) - : base(message) - { - } - } -} diff --git a/src/KubernetesClient/Util/Common/CallGeneratorParams.cs b/src/KubernetesClient/Util/Common/CallGeneratorParams.cs deleted file mode 100644 index fbdc6ac2d..000000000 --- a/src/KubernetesClient/Util/Common/CallGeneratorParams.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace k8s.Util.Common -{ - public class CallGeneratorParams - { - public bool Watch { get; } - public string ResourceVersion { get; } - public int? TimeoutSeconds { get; } - - public CallGeneratorParams(bool watch, string resourceVersion, int? timeoutSeconds) - { - Watch = watch; - ResourceVersion = resourceVersion; - TimeoutSeconds = timeoutSeconds; - } - } -} diff --git a/src/KubernetesClient/Util/Common/CollectionsExtensions.cs b/src/KubernetesClient/Util/Common/CollectionsExtensions.cs deleted file mode 100644 index 6e1b7a51a..000000000 --- a/src/KubernetesClient/Util/Common/CollectionsExtensions.cs +++ /dev/null @@ -1,40 +0,0 @@ -namespace k8s.Util.Common -{ - internal static class CollectionsExtensions - { - public static void AddRange(this HashSet hashSet, ICollection items) - { - if (items == null || hashSet == null) - { - return; - } - - foreach (var item in items) - { - hashSet.Add(item); - } - } - - internal static TValue ComputeIfAbsent(this IDictionary dictionary, TKey key, Func mappingFunction) - { - if (dictionary is null) - { - throw new ArgumentNullException(nameof(dictionary)); - } - - if (dictionary.TryGetValue(key, out var value)) - { - return value; - } - - if (mappingFunction == null) - { - throw new ArgumentNullException(nameof(mappingFunction)); - } - - var newKey = mappingFunction(key); - dictionary[key] = newKey; - return newKey; - } - } -} diff --git a/src/KubernetesClient/Util/Common/Config.cs b/src/KubernetesClient/Util/Common/Config.cs deleted file mode 100644 index f4609d841..000000000 --- a/src/KubernetesClient/Util/Common/Config.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace k8s.Util.Common -{ - public static class Config - { - public static string ServiceAccountCaPath => KubernetesClientConfiguration.ServiceAccountPath + "/ca.crt"; - public static string ServiceAccountTokenPath => KubernetesClientConfiguration.ServiceAccountPath + "/token"; - public static string ServiceAccountNamespacePath => KubernetesClientConfiguration.ServiceAccountPath + "/namespace"; - public static string EnvKubeconfig => "KUBECONFIG"; - public static string EnvServiceHost => "KUBERNETES_SERVICE_HOST"; - public static string EnvServicePort => "KUBERNETES_SERVICE_PORT"; - - // The last resort host to try - public static string DefaultFallbackHost => "http://localhost:8080/"; - } -} diff --git a/src/KubernetesClient/Util/Common/Generic/GenericKubernetesApi.cs b/src/KubernetesClient/Util/Common/Generic/GenericKubernetesApi.cs deleted file mode 100644 index a9e6ebb7d..000000000 --- a/src/KubernetesClient/Util/Common/Generic/GenericKubernetesApi.cs +++ /dev/null @@ -1,647 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using k8s.Models; -using k8s.Util.Common.Generic.Options; -using k8s.Autorest; - -namespace k8s.Util.Common.Generic -{ - /// - /// - /// The Generic kubernetes api provides a unified client interface for not only the non-core-group - /// built-in resources from kubernetes but also the custom-resources models meet the following - /// requirements: - /// - /// 1. there's a `V1ObjectMeta` field in the model along with its getter/setter. 2. there's a - /// `V1ListMeta` field in the list model along with its getter/setter. - supports Json - /// serialization/deserialization. 3. the generic kubernetes api covers all the basic operations over - /// the custom resources including {get, list, watch, create, update, patch, delete}. - /// - /// - For kubernetes-defined failures, the server will return a {@link V1Status} with 4xx/5xx - /// code. The status object will be nested in {@link KubernetesApiResponse#getStatus()} - For the - /// other unknown reason (including network, JVM..), throws an unchecked exception. - /// - public class GenericKubernetesApi - { - private readonly string _apiGroup; - private readonly string _apiVersion; - private readonly string _resourcePlural; - private readonly IKubernetes _client; - - /// - /// Initializes a new instance of the class. - /// - /// the api group"> - /// the api version"> - /// the resource plural, e.g. "jobs""> - /// optional client"> - public GenericKubernetesApi(string apiGroup = default, string apiVersion = default, string resourcePlural = default, IKubernetes apiClient = default) - { - _apiGroup = apiGroup ?? throw new ArgumentNullException(nameof(apiGroup)); - _apiVersion = apiVersion ?? throw new ArgumentNullException(nameof(apiVersion)); - _resourcePlural = resourcePlural ?? throw new ArgumentNullException(nameof(resourcePlural)); - _client = apiClient ?? new Kubernetes(KubernetesClientConfiguration.BuildDefaultConfig()); - } - - /// - /// Get kubernetes object. - /// - /// the object type - /// the object name - /// the token - /// The object - public Task GetAsync(string name, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - return GetAsync(name, new GetOptions(), cancellationToken); - } - - /// - /// Get kubernetes object under the namespaceProperty. - /// - /// the object type - /// the namespaceProperty - /// the name - /// the token - /// the kubernetes object - public Task GetAsync(string namespaceProperty, string name, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - return GetAsync(namespaceProperty, name, new GetOptions(), cancellationToken); - } - - /// - /// List kubernetes object cluster-scoped. - /// - /// the object type - /// the token - /// the kubernetes object - public Task ListAsync(CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - return ListAsync(new ListOptions(), cancellationToken); - } - - /// - /// List kubernetes object under the namespaceProperty. - /// - /// the object type - /// the namespace - /// the token - /// the kubernetes object - public Task ListAsync(string namespaceProperty, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - return ListAsync(namespaceProperty, new ListOptions(), cancellationToken); - } - - /// - /// Create kubernetes object, if the namespaceProperty in the object is present, it will send a - /// namespaceProperty-scoped requests, vice versa. - /// - /// the object type - /// the object - /// the token - /// the kubernetes object - public Task CreateAsync(T obj, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - return CreateAsync(obj, new CreateOptions(), cancellationToken); - } - - /// - /// Create kubernetes object, if the namespaceProperty in the object is present, it will send a - /// namespaceProperty-scoped requests, vice versa. - /// - /// the object - /// the token - /// the object type - /// the kubernetes object - public Task UpdateAsync(T obj, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - return UpdateAsync(obj, new UpdateOptions(), cancellationToken); - } - - /// - /// Patch kubernetes object. - /// - /// the name - /// the string patch content - /// the token - /// the object type - /// the kubernetes object - public Task PatchAsync(string name, object patch, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - return PatchAsync(name, patch, new PatchOptions(), cancellationToken); - } - - /// - /// Patch kubernetes object under the namespaceProperty. - /// - /// the namespaceProperty - /// the name - /// the string patch content - /// the token - /// the object type - /// the kubernetes object - public Task PatchAsync(string namespaceProperty, string name, object patch, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - return PatchAsync(namespaceProperty, name, patch, new PatchOptions(), cancellationToken); - } - - /// - /// Delete kubernetes object. - /// - /// the name - /// the token - /// the object type - /// the kubernetes object - public Task DeleteAsync(string name, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - return DeleteAsync(name, new V1DeleteOptions(), cancellationToken); - } - - /// - /// Delete kubernetes object under the namespaceProperty. - /// - /// the namespaceProperty - /// the name - /// the token - /// the object type - /// the kubernetes object - public Task DeleteAsync(string namespaceProperty, string name, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - return DeleteAsync(namespaceProperty, name, new V1DeleteOptions(), cancellationToken); - } - - /// - /// Creates a cluster-scoped Watch on the resource. - /// - /// action on event - /// action on error - /// action on closed - /// the token - /// the object type - /// the watchable - public Watcher Watch(Action onEvent, Action onError = default, Action onClosed = default, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - return Watch(new ListOptions(), onEvent, onError, onClosed, cancellationToken); - } - - /// - /// Creates a namespaceProperty-scoped Watch on the resource. - /// - /// the object type - /// the namespaceProperty - /// action on event - /// action on error - /// action on closed - /// the token - /// the watchable - public Watcher Watch(string namespaceProperty, Action onEvent, Action onError = default, Action onClosed = default, - CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - return Watch(namespaceProperty, new ListOptions(), onEvent, onError, onClosed, cancellationToken); - } - - // TODO(yue9944882): watch one resource? - - /// - /// Get kubernetes object. - /// - /// the object type - /// the name - /// the get options - /// the token - /// the kubernetes object - public async Task GetAsync(string name, GetOptions getOptions, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - if (string.IsNullOrEmpty(name)) - { - throw new ArgumentNullException(nameof(name)); - } - - var resp = await _client.CustomObjects.GetClusterCustomObjectWithHttpMessagesAsync(group: _apiGroup, plural: _resourcePlural, version: _apiVersion, name: name, cancellationToken: cancellationToken) - .ConfigureAwait(false); - return KubernetesJson.Deserialize(resp.Body.ToString()); - } - - /// - /// Get kubernetes object. - /// - /// the object type - /// the namespaceProperty - /// the name - /// the get options - /// the token - /// the kubernetes object - public async Task GetAsync(string namespaceProperty, string name, GetOptions getOptions, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - if (string.IsNullOrEmpty(name)) - { - throw new ArgumentNullException(nameof(name)); - } - - if (string.IsNullOrEmpty(namespaceProperty)) - { - throw new ArgumentNullException(nameof(namespaceProperty)); - } - - var resp = await _client.CustomObjects.GetNamespacedCustomObjectWithHttpMessagesAsync(group: _apiGroup, plural: _resourcePlural, version: _apiVersion, name: name, namespaceParameter: namespaceProperty, - cancellationToken: cancellationToken).ConfigureAwait(false); - return KubernetesJson.Deserialize(resp.Body.ToString()); - } - - /// - /// List kubernetes object. - /// - /// the object type - /// the list options - /// the token - /// the kubernetes object - public async Task ListAsync(ListOptions listOptions, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - if (listOptions == null) - { - throw new ArgumentNullException(nameof(listOptions)); - } - - var resp = await _client.CustomObjects.ListClusterCustomObjectWithHttpMessagesAsync(group: _apiGroup, plural: _resourcePlural, version: _apiVersion, resourceVersion: listOptions.ResourceVersion, - continueParameter: listOptions.Continue, fieldSelector: listOptions.FieldSelector, labelSelector: listOptions.LabelSelector, limit: listOptions.Limit, - timeoutSeconds: listOptions.TimeoutSeconds, cancellationToken: cancellationToken).ConfigureAwait(false); - return KubernetesJson.Deserialize(resp.Body.ToString()); - } - - /// - /// List kubernetes object. - /// - /// the object type - /// the namespaceProperty - /// the list options - /// the token - /// the kubernetes object - public async Task ListAsync(string namespaceProperty, ListOptions listOptions, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - if (listOptions == null) - { - throw new ArgumentNullException(nameof(listOptions)); - } - - if (string.IsNullOrEmpty(namespaceProperty)) - { - throw new ArgumentNullException(nameof(namespaceProperty)); - } - - var resp = await _client.CustomObjects.ListNamespacedCustomObjectWithHttpMessagesAsync(group: _apiGroup, plural: _resourcePlural, version: _apiVersion, resourceVersion: listOptions.ResourceVersion, - continueParameter: listOptions.Continue, fieldSelector: listOptions.FieldSelector, labelSelector: listOptions.LabelSelector, limit: listOptions.Limit, - timeoutSeconds: listOptions.TimeoutSeconds, namespaceParameter: namespaceProperty, cancellationToken: cancellationToken).ConfigureAwait(false); - - return KubernetesJson.Deserialize(resp.Body.ToString()); - } - - /// - /// Create kubernetes object. - /// - /// the object type - /// the object - /// the create options - /// the token - /// the kubernetes object - public async Task CreateAsync(T obj, CreateOptions createOptions, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - if (obj == null) - { - throw new ArgumentNullException(nameof(obj)); - } - - if (createOptions == null) - { - throw new ArgumentNullException(nameof(createOptions)); - } - - V1ObjectMeta objectMeta = obj.Metadata; - - var isNamespaced = !string.IsNullOrEmpty(objectMeta.NamespaceProperty); - if (isNamespaced) - { - return await CreateAsync(objectMeta.NamespaceProperty, obj, createOptions, cancellationToken).ConfigureAwait(false); - } - - var resp = await _client.CustomObjects.CreateClusterCustomObjectWithHttpMessagesAsync(body: obj, group: _apiGroup, plural: _resourcePlural, version: _apiVersion, dryRun: createOptions.DryRun, - fieldManager: createOptions.FieldManager, cancellationToken: cancellationToken).ConfigureAwait(false); - - return KubernetesJson.Deserialize(resp.Body.ToString()); - } - - /// - /// Create namespaced kubernetes object. - /// - /// the object type - /// the namespace - /// the object - /// the create options - /// the token - /// the kubernetes object - public async Task CreateAsync(string namespaceProperty, T obj, CreateOptions createOptions, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - if (obj == null) - { - throw new ArgumentNullException(nameof(obj)); - } - - if (createOptions == null) - { - throw new ArgumentNullException(nameof(createOptions)); - } - - var resp = await _client.CustomObjects.CreateNamespacedCustomObjectWithHttpMessagesAsync(body: obj, group: _apiGroup, plural: _resourcePlural, version: _apiVersion, - namespaceParameter: namespaceProperty, dryRun: createOptions.DryRun, fieldManager: createOptions.FieldManager, cancellationToken: cancellationToken).ConfigureAwait(false); - - return KubernetesJson.Deserialize(resp.Body.ToString()); - } - - /// - /// Update kubernetes object. - /// - /// the object type - /// the object - /// the update options - /// the token - /// the kubernetes object - public async Task UpdateAsync(T obj, UpdateOptions updateOptions, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - if (obj == null) - { - throw new ArgumentNullException(nameof(obj)); - } - - if (updateOptions == null) - { - throw new ArgumentNullException(nameof(updateOptions)); - } - - V1ObjectMeta objectMeta = obj.Metadata; - - var isNamespaced = !string.IsNullOrEmpty(objectMeta.NamespaceProperty); - HttpOperationResponse resp; - if (isNamespaced) - { - resp = await _client.CustomObjects.ReplaceNamespacedCustomObjectWithHttpMessagesAsync(body: obj, name: objectMeta.Name, group: _apiGroup, plural: _resourcePlural, version: _apiVersion, - namespaceParameter: objectMeta.NamespaceProperty, dryRun: updateOptions.DryRun, fieldManager: updateOptions.FieldManager, cancellationToken: cancellationToken) - .ConfigureAwait(false); - } - else - { - resp = await _client.CustomObjects.ReplaceClusterCustomObjectWithHttpMessagesAsync(body: obj, name: objectMeta.Name, group: _apiGroup ?? obj.ApiGroup(), plural: _resourcePlural, - version: _apiVersion, dryRun: updateOptions.DryRun, fieldManager: updateOptions.FieldManager, cancellationToken: cancellationToken).ConfigureAwait(false); - } - - return KubernetesJson.Deserialize(resp.Body.ToString()); - } - - /// - /// Create kubernetes object, if the namespaceProperty in the object is present, it will send a - /// namespaceProperty-scoped requests, vice versa. - /// - /// the object type - /// the object - /// function to extract the status from the object - /// the token - /// the kubernetes object - public Task UpdateStatusAsync(T obj, Func status, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - return UpdateStatusAsync(obj, status, new UpdateOptions(), cancellationToken); - } - - /// - /// Update status of kubernetes object. - /// - /// the object type - /// the object - /// function to extract the status from the object - /// the update options - /// the token - /// the kubernetes object - public async Task UpdateStatusAsync(T obj, Func status, UpdateOptions updateOptions, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - if (obj == null) - { - throw new ArgumentNullException(nameof(obj)); - } - - if (updateOptions == null) - { - throw new ArgumentNullException(nameof(updateOptions)); - } - - V1ObjectMeta objectMeta = obj.Metadata; - HttpOperationResponse resp; - var isNamespaced = !string.IsNullOrEmpty(objectMeta.NamespaceProperty); - if (isNamespaced) - { - resp = await _client.CustomObjects.PatchNamespacedCustomObjectStatusWithHttpMessagesAsync(body: obj, group: _apiGroup, version: _apiVersion, namespaceParameter: objectMeta.NamespaceProperty, - plural: _resourcePlural, name: objectMeta.Name, dryRun: updateOptions.DryRun, fieldManager: updateOptions.FieldManager, force: updateOptions.Force, - cancellationToken: cancellationToken).ConfigureAwait(false); - } - else - { - resp = await _client.CustomObjects.PatchClusterCustomObjectStatusWithHttpMessagesAsync(body: obj, group: _apiGroup, version: _apiVersion, plural: _resourcePlural, name: objectMeta.Name, - dryRun: updateOptions.DryRun, fieldManager: updateOptions.FieldManager, force: updateOptions.Force, cancellationToken: cancellationToken).ConfigureAwait(false); - } - - return KubernetesJson.Deserialize(resp.Body.ToString()); - } - - /// - /// Patch kubernetes object. - /// - /// the object type - /// the name - /// the object - /// the patch options - /// the token - /// the kubernetes object - public async Task PatchAsync(string name, object obj, PatchOptions patchOptions, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - if (obj == null) - { - throw new ArgumentNullException(nameof(obj)); - } - - if (patchOptions == null) - { - throw new ArgumentNullException(nameof(patchOptions)); - } - - if (string.IsNullOrEmpty(name)) - { - throw new ArgumentNullException(nameof(name)); - } - - var resp = await _client.CustomObjects.PatchClusterCustomObjectWithHttpMessagesAsync(body: obj, group: _apiGroup, version: _apiVersion, plural: _resourcePlural, name: name, dryRun: patchOptions.DryRun, - fieldManager: patchOptions.FieldManager, force: patchOptions.Force, cancellationToken: cancellationToken).ConfigureAwait(false); - return KubernetesJson.Deserialize(resp.Body.ToString()); - } - - /// - /// Patch kubernetes object. - /// - /// the object type - /// the namespaceProperty - /// the name - /// the object - /// the patch options - /// the token - /// the kubernetes object - public async Task PatchAsync(string namespaceProperty, string name, object obj, PatchOptions patchOptions, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - if (string.IsNullOrEmpty(namespaceProperty)) - { - throw new ArgumentNullException(nameof(namespaceProperty)); - } - - if (string.IsNullOrEmpty(name)) - { - throw new ArgumentNullException(nameof(name)); - } - - if (obj == null) - { - throw new ArgumentNullException(nameof(obj)); - } - - if (patchOptions == null) - { - throw new ArgumentNullException(nameof(patchOptions)); - } - - var resp = await _client.CustomObjects.PatchNamespacedCustomObjectWithHttpMessagesAsync(body: obj, group: _apiGroup, version: _apiVersion, namespaceParameter: namespaceProperty, plural: _resourcePlural, - name: name, dryRun: patchOptions.DryRun, fieldManager: patchOptions.FieldManager, force: patchOptions.Force, cancellationToken: cancellationToken).ConfigureAwait(false); - return KubernetesJson.Deserialize(resp.Body.ToString()); - } - - /// - /// Delete kubernetes object. - /// - /// the object type - /// the name - /// the delete options - /// the token - /// the kubernetes object - public async Task DeleteAsync(string name, V1DeleteOptions deleteOptions, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - if (string.IsNullOrEmpty(name)) - { - throw new ArgumentNullException(nameof(name)); - } - - var resp = await _client.CustomObjects.DeleteClusterCustomObjectWithHttpMessagesAsync( - group: _apiGroup, version: _apiVersion, plural: _resourcePlural, name: name, body: deleteOptions, cancellationToken: cancellationToken).ConfigureAwait(false); - return KubernetesJson.Deserialize(resp.Body.ToString()); - } - - /// - /// Delete kubernetes object. - /// - /// the object type - /// the namespaceProperty - /// the name - /// the delete options - /// the token - /// the kubernetes object - public async Task DeleteAsync(string namespaceProperty, string name, V1DeleteOptions deleteOptions, CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - if (string.IsNullOrEmpty(namespaceProperty)) - { - throw new ArgumentNullException(nameof(namespaceProperty)); - } - - if (string.IsNullOrEmpty(name)) - { - throw new ArgumentNullException(nameof(name)); - } - - var resp = await _client.CustomObjects.DeleteNamespacedCustomObjectWithHttpMessagesAsync(group: _apiGroup, version: _apiVersion, namespaceParameter: namespaceProperty, plural: _resourcePlural, - name: name, body: deleteOptions, cancellationToken: cancellationToken).ConfigureAwait(false); - return KubernetesJson.Deserialize(resp.Body.ToString()); - } - - /// - /// Watch watchable. - /// - /// the list options - /// action on event - /// action on error - /// action on closed - /// the token - /// the object type - /// the watchable - public Watcher Watch(ListOptions listOptions, Action onEvent, Action onError = default, Action onClosed = default, - CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - if (listOptions == null) - { - throw new ArgumentNullException(nameof(listOptions)); - } - - var resp = _client.CustomObjects.ListClusterCustomObjectWithHttpMessagesAsync(group: _apiGroup, version: _apiVersion, plural: _resourcePlural, continueParameter: listOptions.Continue, - fieldSelector: listOptions.FieldSelector, labelSelector: listOptions.LabelSelector, limit: listOptions.Limit, resourceVersion: listOptions.ResourceVersion, - timeoutSeconds: listOptions.TimeoutSeconds, watch: true, cancellationToken: cancellationToken); - - return resp.Watch(onEvent, onError, onClosed); - } - - /// - /// Watch watchable. - /// - /// the namespaceProperty - /// the list options - /// action on event - /// action on error - /// action on closed - /// the token - /// the object type - /// the watchable - public Watcher Watch(string namespaceProperty, ListOptions listOptions, Action onEvent, Action onError = default, Action onClosed = default, - CancellationToken cancellationToken = default) - where T : class, IKubernetesObject - { - if (listOptions == null) - { - throw new ArgumentNullException(nameof(listOptions)); - } - - if (string.IsNullOrEmpty(namespaceProperty)) - { - throw new ArgumentNullException(nameof(namespaceProperty)); - } - - var resp = _client.CustomObjects.ListNamespacedCustomObjectWithHttpMessagesAsync(group: _apiGroup, version: _apiVersion, namespaceParameter: namespaceProperty, plural: _resourcePlural, - continueParameter: listOptions.Continue, fieldSelector: listOptions.FieldSelector, labelSelector: listOptions.LabelSelector, limit: listOptions.Limit, - resourceVersion: listOptions.ResourceVersion, timeoutSeconds: listOptions.TimeoutSeconds, watch: true, cancellationToken: cancellationToken); - - return resp.Watch(onEvent, onError, onClosed); - } - } -} diff --git a/src/KubernetesClient/Util/Common/Generic/KubernetesApiResponse.cs b/src/KubernetesClient/Util/Common/Generic/KubernetesApiResponse.cs deleted file mode 100644 index 086878380..000000000 --- a/src/KubernetesClient/Util/Common/Generic/KubernetesApiResponse.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System.Net; -using k8s.Models; - -namespace k8s.Util.Common.Generic -{ - public class KubernetesApiResponse - where TDataType : IKubernetesObject - { - public KubernetesApiResponse(TDataType @object) - { - Object = @object; - Status = null; - HttpStatusCode = HttpStatusCode.OK; // 200 - } - - public KubernetesApiResponse(V1Status status, HttpStatusCode httpStatusCode) - { - Object = default(TDataType); - Status = status; - HttpStatusCode = httpStatusCode; - } - - public TDataType Object { get; } - - public V1Status Status { get; } - - public HttpStatusCode HttpStatusCode { get; } - - public bool IsSuccess => ((int)HttpStatusCode > 199 && (int)HttpStatusCode < 300); // 400 - - /// - /// Throws api exception kubernetes api response on failure. This is the recommended approach to - /// deal with errors returned from server. - /// - /// the kubernetes api response - /// the api exception - public KubernetesApiResponse ThrowsApiException() - { - return OnFailure(new ErrorStatusHandler()); - } - - /// - /// Calling errorStatusHandler upon errors from server - /// - /// the error status handler - /// the kubernetes api response - public KubernetesApiResponse OnFailure(ErrorStatusHandler errorStatusHandler) - { - if (!IsSuccess && errorStatusHandler != null) - { - errorStatusHandler.Handle((int)HttpStatusCode, Status); - } - - return this; - } - - public class ErrorStatusHandler - { - public void Handle(int code, V1Status errorStatus) - { - throw new HttpListenerException(code, errorStatus?.Message); - } - } - } -} diff --git a/src/KubernetesClient/Util/Common/Generic/Options/CreateOptions.cs b/src/KubernetesClient/Util/Common/Generic/Options/CreateOptions.cs deleted file mode 100644 index 4f03284fa..000000000 --- a/src/KubernetesClient/Util/Common/Generic/Options/CreateOptions.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace k8s.Util.Common.Generic.Options -{ - public class CreateOptions - { - public string DryRun { get; private set; } - - public string FieldManager { get; private set; } - - public CreateOptions(string dryRun = default, string fieldManager = default) - { - DryRun = dryRun; - FieldManager = fieldManager; - } - } -} diff --git a/src/KubernetesClient/Util/Common/Generic/Options/GetOptions.cs b/src/KubernetesClient/Util/Common/Generic/Options/GetOptions.cs deleted file mode 100644 index 7a1425f0b..000000000 --- a/src/KubernetesClient/Util/Common/Generic/Options/GetOptions.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace k8s.Util.Common.Generic.Options -{ - public class GetOptions - { - } -} diff --git a/src/KubernetesClient/Util/Common/Generic/Options/ListOptions.cs b/src/KubernetesClient/Util/Common/Generic/Options/ListOptions.cs deleted file mode 100644 index 7750ad6b9..000000000 --- a/src/KubernetesClient/Util/Common/Generic/Options/ListOptions.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace k8s.Util.Common.Generic.Options -{ - public class ListOptions - { - public int? TimeoutSeconds { get; private set; } - - public int Limit { get; private set; } - - public string FieldSelector { get; private set; } - - public string LabelSelector { get; private set; } - - public string ResourceVersion { get; private set; } - - public string Continue { get; private set; } - - public ListOptions(int? timeoutSeconds = default, int limit = default, string fieldSelector = default, string labelSelector = default, string resourceVersion = default, - string @continue = default) - { - TimeoutSeconds = timeoutSeconds; - Limit = limit; - FieldSelector = fieldSelector; - LabelSelector = labelSelector; - ResourceVersion = resourceVersion; - Continue = @continue; - } - } -} diff --git a/src/KubernetesClient/Util/Common/Generic/Options/PatchOptions.cs b/src/KubernetesClient/Util/Common/Generic/Options/PatchOptions.cs deleted file mode 100644 index ed81e1d51..000000000 --- a/src/KubernetesClient/Util/Common/Generic/Options/PatchOptions.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace k8s.Util.Common.Generic.Options -{ - public class PatchOptions - { - public string DryRun { get; private set; } - - public bool Force { get; private set; } - - public string FieldManager { get; private set; } - - public PatchOptions(string dryRun = default, bool force = false, string fieldManager = default) - { - DryRun = dryRun; - Force = force; - FieldManager = fieldManager; - } - } -} diff --git a/src/KubernetesClient/Util/Common/Generic/Options/UpdateOptions.cs b/src/KubernetesClient/Util/Common/Generic/Options/UpdateOptions.cs deleted file mode 100644 index 3fcedd8f1..000000000 --- a/src/KubernetesClient/Util/Common/Generic/Options/UpdateOptions.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace k8s.Util.Common.Generic.Options -{ - public class UpdateOptions - { - public string DryRun { get; private set; } - - public bool Force { get; private set; } - - public string FieldManager { get; private set; } - - public UpdateOptions(string dryRun = default, bool force = false, string fieldManager = default) - { - DryRun = dryRun; - Force = force; - FieldManager = fieldManager; - } - } -} diff --git a/src/KubernetesClient/Util/Common/Namespaces.cs b/src/KubernetesClient/Util/Common/Namespaces.cs deleted file mode 100644 index 1bb705c34..000000000 --- a/src/KubernetesClient/Util/Common/Namespaces.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.IO; -using System.Text; - -namespace k8s.Util.Common -{ - /// - /// Namespaces provides a set of helpers for operating namespaces. - /// - public class Namespaces - { - public const string NamespaceAll = ""; - - public const string NamespaceDefault = "default"; - - public const string NamespaceKubeSystem = "kube-system"; - - public static string GetPodNamespace() - { - return File.ReadAllText(Config.ServiceAccountNamespacePath, Encoding.UTF8); - } - } -} diff --git a/src/KubernetesClient/Util/Informer/Cache/Cache.cs b/src/KubernetesClient/Util/Informer/Cache/Cache.cs deleted file mode 100644 index 2236c3df0..000000000 --- a/src/KubernetesClient/Util/Informer/Cache/Cache.cs +++ /dev/null @@ -1,441 +0,0 @@ -using k8s.Models; -using k8s.Util.Common; - -namespace k8s.Util.Informer.Cache -{ - /// - /// Cache is a C# port of Java's Cache which is a port of k/client-go's ThreadSafeStore. It basically saves and indexes all the entries. - /// - /// The type of K8s object to save - public class Cache : IIndexer - where TApiType : class, IKubernetesObject - { - /// - /// keyFunc defines how to map index objects into indices - /// - private Func, string> _keyFunc; - - /// - /// indexers stores index functions by their names - /// - /// The indexer name(string) is a label marking the different ways it can be calculated. - /// The default label is "namespace". The default func is to look in the object's metadata and combine the - /// namespace and name values, as namespace/name. - /// - private readonly Dictionary>> _indexers = new Dictionary>>(); - - /// - /// indices stores objects' keys by their indices - /// - /// Similar to 'indexers', an indice has the same label as its corresponding indexer except it's value - /// is the result of the func. - /// if the indexer func is to calculate the namespace and name values as namespace/name, then the indice HashSet - /// holds those values. - /// - private Dictionary>> _indices = new Dictionary>>(); - - /// - /// items stores object instances - /// - /// Indices hold the HashSet of calculated keys (namespace/name) for a given resource and items map each of - /// those keys to actual K8s object that was originally returned. - private Dictionary _items = new Dictionary(); - - /// - /// object used to track locking - /// - /// methods interacting with the store need to lock to secure the thread for race conditions, - /// learn more: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/lock-statement - private readonly object _lock = new object(); - - /// - /// Initializes a new instance of the class. Uses an object's namespace as the key. - /// - public Cache() - : this(Caches.NamespaceIndex, Caches.MetaNamespaceIndexFunc, Caches.DeletionHandlingMetaNamespaceKeyFunc) - { - } - - /// - /// Initializes a new instance of the class. - /// Constructor. - /// - /// the index name, an unique name representing the index - /// the index func by which we map multiple object to an index for querying - /// the key func by which we map one object to an unique key for storing - public Cache(string indexName, Func> indexFunc, Func, string> keyFunc) - { - _indexers[indexName] = indexFunc; - _keyFunc = keyFunc; - _indices[indexName] = new Dictionary>(); - } - - public void Clear() - { - lock (_lock) - { - _items?.Clear(); - _indices?.Clear(); - _indexers?.Clear(); - } - } - - /// - /// Add objects. - /// - /// the obj - public void Add(TApiType obj) - { - var key = _keyFunc(obj); - - lock (_lock) - { - var oldObj = _items.GetValueOrDefault(key); - _items[key] = obj; - UpdateIndices(oldObj, obj, key); - } - } - - /// - /// Update the object. - /// - /// the obj - public void Update(TApiType obj) - { - var key = _keyFunc(obj); - - lock (_lock) - { - var oldObj = _items.GetValueOrDefault(key); - _items[key] = obj; - UpdateIndices(oldObj, obj, key); - } - } - - /// - /// Delete the object. - /// - /// the obj - public void Delete(TApiType obj) - { - var key = _keyFunc(obj); - lock (_lock) - { - if (!_items.TryGetValue(key, out var value)) - { - return; - } - - DeleteFromIndices(value, key); - _items.Remove(key); - } - } - - /// - /// Replace the content in the cache completely. - /// - /// the list - /// optional, unused param from interface - /// list is null - public void Replace(IEnumerable list, string resourceVersion = default) - { - if (list is null) - { - throw new ArgumentNullException(nameof(list)); - } - - var newItems = new Dictionary(); - foreach (var item in list) - { - var key = _keyFunc(item); - newItems[key] = item; - } - - lock (_lock) - { - _items = newItems; - - // rebuild any index - _indices = new Dictionary>>(); - foreach (var (key, value) in _items) - { - UpdateIndices(default, value, key); - } - } - } - - /// - /// Resync. - /// - public void Resync() - { - // Do nothing by default - } - - /// - /// List keys. - /// - /// the list - public IEnumerable ListKeys() - { - return _items.Select(item => item.Key); - } - - /// - /// Get object t. - /// - /// the obj - /// the t - public TApiType Get(TApiType obj) - { - var key = _keyFunc(obj); - - lock (_lock) - { - // Todo: to make this lock striped or reader/writer (or use ConcurrentDictionary) - return _items.GetValueOrDefault(key); - } - } - - /// - /// List all objects in the cache. - /// - /// all items - public IEnumerable List() - { - lock (_lock) - { - return _items.Select(item => item.Value); - } - } - - /// - /// Get object t. - /// - /// the key - /// the get by key - public TApiType GetByKey(string key) - { - lock (_lock) - { - _items.TryGetValue(key, out var value); - return value; - } - } - - /// - /// Get objects. - /// - /// the index name - /// the obj - /// the list - /// indexers does not contain the provided index name - public IEnumerable Index(string indexName, TApiType obj) - { - if (!_indexers.ContainsKey(indexName)) - { - throw new ArgumentException($"index {indexName} doesn't exist!", nameof(indexName)); - } - - lock (_lock) - { - var indexFunc = _indexers[indexName]; - var indexKeys = indexFunc(obj); - var index = _indices.GetValueOrDefault(indexName); - if (index is null || index.Count == 0) - { - return new List(); - } - - var returnKeySet = new HashSet(); - foreach (var set in indexKeys.Select(indexKey => index.GetValueOrDefault(indexKey)).Where(set => set != null && set.Count != 0)) - { - returnKeySet.AddRange(set); - } - - var items = new List(returnKeySet.Count); - items.AddRange(returnKeySet.Select(absoluteKey => _items[absoluteKey])); - - return items; - } - } - - /// - /// Index keys list. - /// - /// the index name - /// the index key - /// the list - /// indexers does not contain the provided index name - /// indices collection does not contain the provided index name - public IEnumerable IndexKeys(string indexName, string indexKey) - { - if (!_indexers.ContainsKey(indexName)) - { - throw new ArgumentException($"index {indexName} doesn't exist!", nameof(indexName)); - } - - lock (_lock) - { - var index = _indices.GetValueOrDefault(indexName); - - if (index is null) - { - throw new KeyNotFoundException($"no value could be found for name '{indexName}'"); - } - - return index[indexKey]; - } - } - - /// - /// By index list. - /// - /// the index name - /// the index key - /// the list - /// indexers does not contain the provided index name - /// indices collection does not contain the provided index name - public IEnumerable ByIndex(string indexName, string indexKey) - { - if (!_indexers.ContainsKey(indexName)) - { - throw new ArgumentException($"index {indexName} doesn't exist!", nameof(indexName)); - } - - var index = _indices.GetValueOrDefault(indexName); - - if (index is null) - { - throw new KeyNotFoundException($"no value could be found for name '{indexName}'"); - } - - var set = index[indexKey]; - return set is null ? new List() : set.Select(key => _items[key]); - } - - /// - /// Return the indexers registered with the cache. - /// - /// registered indexers - public IDictionary>> GetIndexers() => _indexers; - - /// - /// Add additional indexers to the cache. - /// - /// indexers to add - /// newIndexers is null - /// items collection is not empty - /// conflict between keys in existing index and new indexers provided - public void AddIndexers(IDictionary>> newIndexers) - { - if (newIndexers is null) - { - throw new ArgumentNullException(nameof(newIndexers)); - } - - if (_items.Any()) - { - throw new InvalidOperationException("cannot add indexers to a non-empty cache"); - } - - var oldKeys = _indexers.Keys; - var newKeys = newIndexers.Keys; - var intersection = oldKeys.Intersect(newKeys); - - if (intersection.Any()) - { - throw new ArgumentException("indexer conflict: " + intersection); - } - - foreach (var (key, value) in newIndexers) - { - AddIndexFunc(key, value); - } - } - - /// - /// UpdateIndices modifies the objects location in the managed indexes, if this is an update, you - /// must provide an oldObj. - /// - /// UpdateIndices must be called from a function that already has a lock on the cache. - /// the old obj - /// the new obj - /// the key - private void UpdateIndices(TApiType oldObj, TApiType newObj, string key) - { - // if we got an old object, we need to remove it before we can add - // it again. - if (oldObj != null) - { - DeleteFromIndices(oldObj, key); - } - - foreach (var (indexName, indexFunc) in _indexers) - { - var indexValues = indexFunc(newObj); - if (indexValues is null || indexValues.Count == 0) - { - continue; - } - - var index = _indices.ComputeIfAbsent(indexName, _ => new Dictionary>()); - - foreach (var indexValue in indexValues) - { - HashSet indexSet = index.ComputeIfAbsent(indexValue, k => new HashSet()); - indexSet.Add(key); - - index[indexValue] = indexSet; - } - } - } - - /// - /// DeleteFromIndices removes the object from each of the managed indexes. - /// - /// It is intended to be called from a function that already has a lock on the cache. - /// the old obj - /// the key - private void DeleteFromIndices(TApiType oldObj, string key) - { - foreach (var (s, indexFunc) in _indexers) - { - var indexValues = indexFunc(oldObj); - if (indexValues is null || indexValues.Count == 0) - { - continue; - } - - var index = _indices.GetValueOrDefault(s); - if (index is null) - { - continue; - } - - foreach (var indexSet in indexValues.Select(indexValue => index[indexValue])) - { - indexSet?.Remove(key); - } - } - } - - /// - /// Add index func. - /// - /// the index name - /// the index func - public void AddIndexFunc(string indexName, Func> indexFunc) - { - _indices[indexName] = new Dictionary>(); - _indexers[indexName] = indexFunc; - } - - public Func, string> KeyFunc => _keyFunc; - - public void SetKeyFunc(Func, string> keyFunc) - { - _keyFunc = keyFunc; - } - } -} diff --git a/src/KubernetesClient/Util/Informer/Cache/Caches.cs b/src/KubernetesClient/Util/Informer/Cache/Caches.cs deleted file mode 100644 index 21339b015..000000000 --- a/src/KubernetesClient/Util/Informer/Cache/Caches.cs +++ /dev/null @@ -1,83 +0,0 @@ -using k8s.Models; - -namespace k8s.Util.Informer.Cache -{ - /// - /// A set of helper utilities for constructing a cache. - /// - public static class Caches - { - /// - /// NamespaceIndex is the default index function for caching objects - /// - public const string NamespaceIndex = "namespace"; - - /// - /// deletionHandlingMetaNamespaceKeyFunc checks for DeletedFinalStateUnknown objects before calling - /// metaNamespaceKeyFunc. - /// - /// specific object - /// the type parameter - /// if obj is null - /// the key - public static string DeletionHandlingMetaNamespaceKeyFunc(TApiType obj) - where TApiType : class, IKubernetesObject - { - if (obj is null) - { - throw new ArgumentNullException(nameof(obj)); - } - - if (obj.GetType() == typeof(DeletedFinalStateUnknown)) - { - var deleteObj = obj as DeletedFinalStateUnknown; - return deleteObj.GetKey(); - } - - return MetaNamespaceKeyFunc(obj); - } - - /// - /// MetaNamespaceKeyFunc is a convenient default KeyFunc which knows how to make keys for API - /// objects which implement V1ObjectMeta Interface. The key uses the format <namespace>/<name> - /// unless <namespace> is empty, then it's just <name>. - /// - /// specific object - /// the key - /// if obj is null - /// if metadata can't be found on obj - public static string MetaNamespaceKeyFunc(IKubernetesObject obj) - { - if (obj is null) - { - throw new ArgumentNullException(nameof(obj)); - } - - if (!string.IsNullOrEmpty(obj.Metadata.NamespaceProperty)) - { - return obj.Metadata.NamespaceProperty + "/" + obj.Metadata.Name; - } - - return obj.Metadata.Name; - } - - /// - /// MetaNamespaceIndexFunc is a default index function that indexes based on an object's namespace. - /// - /// specific object - /// the type parameter - /// the indexed value - /// if obj is null - /// if metadata can't be found on obj - public static List MetaNamespaceIndexFunc(TApiType obj) - where TApiType : IKubernetesObject - { - if (obj is null) - { - throw new ArgumentNullException(nameof(obj)); - } - - return obj.Metadata is null ? new List() : new List() { obj.Metadata.NamespaceProperty }; - } - } -} diff --git a/src/KubernetesClient/Util/Informer/Cache/DeletedFinalStateUnknown.cs b/src/KubernetesClient/Util/Informer/Cache/DeletedFinalStateUnknown.cs deleted file mode 100644 index 7e8a99553..000000000 --- a/src/KubernetesClient/Util/Informer/Cache/DeletedFinalStateUnknown.cs +++ /dev/null @@ -1,47 +0,0 @@ -using k8s.Models; - -namespace k8s.Util.Informer.Cache -{ - // DeletedFinalStateUnknown is placed into a DeltaFIFO in the case where - // an object was deleted but the watch deletion event was missed. In this - // case we don't know the final "resting" state of the object, so there's - // a chance the included `Obj` is stale. - public class DeletedFinalStateUnknown : IKubernetesObject - where TApi : class, IKubernetesObject - { - private readonly string _key; - private readonly TApi _obj; - - public DeletedFinalStateUnknown(string key, TApi obj) - { - _key = key; - _obj = obj; - } - - public string GetKey() => _key; - - /// - /// Gets get obj. - /// - /// the get obj - public TApi GetObj() => _obj; - - public V1ObjectMeta Metadata - { - get => _obj.Metadata; - set => _obj.Metadata = value; - } - - public string ApiVersion - { - get => _obj.ApiVersion; - set => _obj.ApiVersion = value; - } - - public string Kind - { - get => _obj.Kind; - set => _obj.Kind = value; - } - } -} diff --git a/src/KubernetesClient/Util/Informer/Cache/DeltaType.cs b/src/KubernetesClient/Util/Informer/Cache/DeltaType.cs deleted file mode 100644 index b8f10c4fa..000000000 --- a/src/KubernetesClient/Util/Informer/Cache/DeltaType.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace k8s.Util.Informer.Cache -{ - public enum DeltaType - { - /// - /// Item added - /// - Added, - - /// - /// Item updated - /// - Updated, - - /// - /// Item deleted - /// - Deleted, - - /// - /// Item synchronized - /// - Sync, - - /// - /// Item replaced - /// - Replaced, - } -} diff --git a/src/KubernetesClient/Util/Informer/Cache/IIndexer.cs b/src/KubernetesClient/Util/Informer/Cache/IIndexer.cs deleted file mode 100644 index 76f6fae76..000000000 --- a/src/KubernetesClient/Util/Informer/Cache/IIndexer.cs +++ /dev/null @@ -1,44 +0,0 @@ -using k8s.Models; - -namespace k8s.Util.Informer.Cache -{ - public interface IIndexer : IStore - where TApiType : class, IKubernetesObject - { - /// - /// Retrieve list of objects that match on the named indexing function. - /// - /// specific indexing function - /// . - /// matched objects - IEnumerable Index(string indexName, TApiType obj); - - /// - /// IndexKeys returns the set of keys that match on the named indexing function. - /// - /// specific indexing function - /// specific index key - /// matched keys - IEnumerable IndexKeys(string indexName, string indexKey); - - /// - /// ByIndex lists object that match on the named indexing function with the exact key. - /// - /// specific indexing function - /// specific index key - /// matched objects - IEnumerable ByIndex(string indexName, string indexKey); - - /// - /// Return the indexers registered with the store. - /// - /// registered indexers - IDictionary>> GetIndexers(); - - /// - /// Add additional indexers to the store. - /// - /// indexers to add - void AddIndexers(IDictionary>> indexers); - } -} diff --git a/src/KubernetesClient/Util/Informer/Cache/IStore.cs b/src/KubernetesClient/Util/Informer/Cache/IStore.cs deleted file mode 100644 index 68d07506f..000000000 --- a/src/KubernetesClient/Util/Informer/Cache/IStore.cs +++ /dev/null @@ -1,69 +0,0 @@ -using k8s.Models; - -namespace k8s.Util.Informer.Cache -{ - public interface IStore - where TApiType : class, IKubernetesObject - { - /// - /// add inserts an item into the store. - /// - /// specific obj - void Add(TApiType obj); - - /// - /// update sets an item in the store to its updated state. - /// - /// specific obj - void Update(TApiType obj); - - /// - /// delete removes an item from the store. - /// - /// specific obj - void Delete(TApiType obj); - - /// - /// Replace will delete the contents of 'c', using instead the given list. - /// - /// list of objects - /// specific resource version - void Replace(IEnumerable list, string resourceVersion); - - /// - /// resync will send a resync event for each item. - /// - void Resync(); - - /// - /// listKeys returns a list of all the keys of the object currently in the store. - /// - /// list of all keys - IEnumerable ListKeys(); - - /// - /// get returns the requested item. - /// - /// specific obj - /// the requested item if exist - TApiType Get(TApiType obj); - - /// - /// getByKey returns the request item with specific key. - /// - /// specific key - /// the request item - TApiType GetByKey(string key); - - /// - /// list returns a list of all the items. - /// - /// list of all the items - IEnumerable List(); - - /// - /// Empty the store - /// - void Clear(); - } -} diff --git a/src/KubernetesClient/Util/Informer/Cache/Lister.cs b/src/KubernetesClient/Util/Informer/Cache/Lister.cs deleted file mode 100644 index e651f1257..000000000 --- a/src/KubernetesClient/Util/Informer/Cache/Lister.cs +++ /dev/null @@ -1,44 +0,0 @@ -using k8s.Models; - -namespace k8s.Util.Informer.Cache -{ - /// - /// Lister interface is used to list cached items from a running informer. - /// - /// the type - public class Lister - where TApiType : class, IKubernetesObject - { - private readonly string _namespace; - private readonly string _indexName; - private readonly IIndexer _indexer; - - public Lister(IIndexer indexer, string @namespace = default, string indexName = Caches.NamespaceIndex) - { - _indexer = indexer; - _namespace = @namespace; - _indexName = indexName; - } - - public IEnumerable List() - { - return string.IsNullOrEmpty(_namespace) ? _indexer.List() : _indexer.ByIndex(_indexName, _namespace); - } - - public TApiType Get(string name) - { - var key = name; - if (!string.IsNullOrEmpty(_namespace)) - { - key = _namespace + "/" + name; - } - - return _indexer.GetByKey(key); - } - - public Lister Namespace(string @namespace) - { - return new Lister(_indexer, @namespace, Caches.NamespaceIndex); - } - } -} diff --git a/src/KubernetesClient/Util/Informer/Cache/MutablePair.cs b/src/KubernetesClient/Util/Informer/Cache/MutablePair.cs deleted file mode 100644 index f412d1001..000000000 --- a/src/KubernetesClient/Util/Informer/Cache/MutablePair.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace k8s.Util.Informer.Cache -{ - public class MutablePair - { - protected bool Equals(MutablePair other) - { - if (other is null) - { - throw new ArgumentNullException(nameof(other)); - } - - return EqualityComparer.Default.Equals(Left, other.Left) && EqualityComparer.Default.Equals(Right, other.Right); - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - return obj.GetType() == this.GetType() && Equals((MutablePair)obj); - } - - public override int GetHashCode() - { - unchecked - { - return (EqualityComparer.Default.GetHashCode(Left) * 397) ^ EqualityComparer.Default.GetHashCode(Right); - } - } - - public TRight Right { get; } - - public TLeft Left { get; } - - public MutablePair() - { - } - - public MutablePair(TLeft left, TRight right) - { - Left = left; - Right = right; - } - } -} diff --git a/src/KubernetesClient/Watcher.cs b/src/KubernetesClient/Watcher.cs index f8d4c4ecf..23868d4e0 100644 --- a/src/KubernetesClient/Watcher.cs +++ b/src/KubernetesClient/Watcher.cs @@ -1,13 +1,12 @@ -using System.IO; using System.Runtime.CompilerServices; using System.Runtime.Serialization; -using System.Threading; -using System.Threading.Tasks; -using k8s.Models; namespace k8s { /// Describes the type of a watch event. +#if NET8_0_OR_GREATER + [JsonConverter(typeof(JsonStringEnumConverter))] +#endif public enum WatchEventType { /// Emitted when an object is created, modified to match a watch's filter, or when a watch is first opened. diff --git a/src/KubernetesClient/WatcherExt.cs b/src/KubernetesClient/WatcherExt.cs index 4cf7a82ce..28863341f 100644 --- a/src/KubernetesClient/WatcherExt.cs +++ b/src/KubernetesClient/WatcherExt.cs @@ -1,7 +1,4 @@ -using System.IO; -using System.Threading.Tasks; using k8s.Exceptions; -using k8s.Autorest; namespace k8s { @@ -14,11 +11,12 @@ public static class WatcherExt /// type of the HttpOperationResponse object /// the api response /// a callback when any event raised from api server - /// a callbak when any exception was caught during watching + /// a callback when any exception was caught during watching /// /// The action to invoke when the server closes the connection. /// /// a watch object + [Obsolete("This method will be deprecated in future versions. Please use the Watch method instead.")] public static Watcher Watch( this Task> responseTask, Action onEvent, @@ -50,11 +48,12 @@ private static Func> MakeStreamReaderCreator(Tasktype of the HttpOperationResponse object /// the api response /// a callback when any event raised from api server - /// a callbak when any exception was caught during watching + /// a callback when any exception was caught during watching /// /// The action to invoke when the server closes the connection. /// /// a watch object + [Obsolete("This method will be deprecated in future versions. Please use the Watch method instead.")] public static Watcher Watch( this HttpOperationResponse response, Action onEvent, @@ -71,13 +70,16 @@ public static Watcher Watch( /// type of the event object /// type of the HttpOperationResponse object /// the api response - /// a callbak when any exception was caught during watching + /// a callback when any exception was caught during watching + /// cancellation token /// IAsyncEnumerable of watch events + [Obsolete("This method will be deprecated in future versions. Please use the WatchAsync method instead.")] public static IAsyncEnumerable<(WatchEventType, T)> WatchAsync( this Task> responseTask, - Action onError = null) + Action onError = null, + CancellationToken cancellationToken = default) { - return Watcher.CreateWatchEventEnumerator(MakeStreamReaderCreator(responseTask), onError); + return Watcher.CreateWatchEventEnumerator(MakeStreamReaderCreator(responseTask), onError, cancellationToken); } } } diff --git a/src/KubernetesClient/WebSocketBuilder.cs b/src/KubernetesClient/WebSocketBuilder.cs index 053acf29b..8acc3c5ce 100644 --- a/src/KubernetesClient/WebSocketBuilder.cs +++ b/src/KubernetesClient/WebSocketBuilder.cs @@ -1,7 +1,5 @@ using System.Net.WebSockets; using System.Security.Cryptography.X509Certificates; -using System.Threading; -using System.Threading.Tasks; namespace k8s { diff --git a/src/LibKubernetesGenerator/ApiGenerator.cs b/src/LibKubernetesGenerator/ApiGenerator.cs index 8c151fdb7..37f135db5 100644 --- a/src/LibKubernetesGenerator/ApiGenerator.cs +++ b/src/LibKubernetesGenerator/ApiGenerator.cs @@ -1,14 +1,21 @@ -using System.Collections.Generic; -using System.Linq; using CaseExtensions; using Microsoft.CodeAnalysis; using NSwag; +using System.Collections.Generic; +using System.Linq; namespace LibKubernetesGenerator { internal class ApiGenerator { - public void Generate(OpenApiDocument swagger, GeneratorExecutionContext context) + private readonly ScriptObjectFactory scriptObjectFactory; + + public ApiGenerator(ScriptObjectFactory scriptObjectFactory) + { + this.scriptObjectFactory = scriptObjectFactory; + } + + public void Generate(OpenApiDocument swagger, IncrementalGeneratorPostInitializationContext context) { var data = swagger.Operations .Where(o => o.Method != OpenApiOperationMethod.Options) @@ -42,6 +49,8 @@ public void Generate(OpenApiDocument swagger, GeneratorExecutionContext context) }) .ToArray(); + var sc = scriptObjectFactory.CreateScriptObject(); + var groups = new List(); foreach (var grouped in data.GroupBy(d => d.Operation.Tags.First())) @@ -50,14 +59,20 @@ public void Generate(OpenApiDocument swagger, GeneratorExecutionContext context) groups.Add(name); var apis = grouped.ToArray(); - var gctx = new { name, apis }; - context.RenderToContext($"IOperations.cs.template", gctx, $"I{name}Operations.g.cs"); - context.RenderToContext("Operations.cs.template", gctx, $"{name}Operations.g.cs"); - context.RenderToContext("OperationsExtensions.cs.template", gctx, $"{name}OperationsExtensions.g.cs"); + + sc.SetValue("name", name, true); + sc.SetValue("apis", apis, true); + + context.RenderToContext($"IOperations.cs.template", sc, $"I{name}Operations.g.cs"); + context.RenderToContext("Operations.cs.template", sc, $"{name}Operations.g.cs"); + context.RenderToContext("OperationsExtensions.cs.template", sc, $"{name}OperationsExtensions.g.cs"); } - context.RenderToContext($"IBasicKubernetes.cs.template", groups, $"IBasicKubernetes.g.cs"); - context.RenderToContext($"AbstractKubernetes.cs.template", groups, $"AbstractKubernetes.g.cs"); + sc = scriptObjectFactory.CreateScriptObject(); + sc.SetValue("groups", groups, true); + + context.RenderToContext($"IKubernetes.cs.template", sc, $"IKubernetes.g.cs"); + context.RenderToContext($"AbstractKubernetes.cs.template", sc, $"AbstractKubernetes.g.cs"); } } } diff --git a/src/LibKubernetesGenerator/ClassNameHelper.cs b/src/LibKubernetesGenerator/ClassNameHelper.cs index 434091ee6..a3b012f29 100644 --- a/src/LibKubernetesGenerator/ClassNameHelper.cs +++ b/src/LibKubernetesGenerator/ClassNameHelper.cs @@ -1,13 +1,14 @@ -using System.Collections.Generic; -using System.Linq; using CaseExtensions; using NJsonSchema; using NSwag; -using Nustache.Core; +using Scriban.Runtime; +using System; +using System.Collections.Generic; +using System.Linq; namespace LibKubernetesGenerator { - internal class ClassNameHelper : INustacheHelper + internal class ClassNameHelper : IScriptObjectHelper { private readonly Dictionary classNameMap; private readonly Dictionary schemaToNameMapCooked; @@ -18,9 +19,10 @@ public ClassNameHelper(OpenApiDocument swagger) schemaToNameMapCooked = GenerateSchemaToNameMapCooked(swagger); } - public void RegisterHelper() + + public void RegisterHelper(ScriptObject scriptObject) { - Helpers.Register(nameof(GetClassName), GetClassName); + scriptObject.Import(nameof(GetClassName), new Func(GetClassNameForSchemaDefinition)); } private static Dictionary GenerateSchemaToNameMapCooked(OpenApiDocument swagger) @@ -50,27 +52,7 @@ private Dictionary InitClassNameMap(OpenApiDocument doc) return map; } - public void GetClassName(RenderContext context, IList arguments, IDictionary options, - RenderBlock fn, RenderBlock inverse) - { - if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is OpenApiOperation) - { - context.Write(GetClassName(arguments[0] as OpenApiOperation)); - } - else if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is JsonSchema) - { - context.Write(GetClassNameForSchemaDefinition(arguments[0] as JsonSchema)); - } - } - - public string GetClassName(OpenApiOperation operation) - { - var groupVersionKind = - (Dictionary)operation.ExtensionData["x-kubernetes-group-version-kind"]; - return GetClassName(groupVersionKind); - } - - public string GetClassName(Dictionary groupVersionKind) + private string GetClassName(Dictionary groupVersionKind) { var group = (string)groupVersionKind["group"]; var kind = (string)groupVersionKind["kind"]; @@ -96,12 +78,13 @@ public string GetClassNameForSchemaDefinition(JsonSchema definition) } - return schemaToNameMapCooked[definition]; - } + if (definition.Format == "int-or-string") + { + return "IntOrString"; + } - private static Dictionary InitSchemaToNameCooked(OpenApiDocument swagger) - { - return swagger.Definitions.ToDictionary(x => x.Value, x => x.Key.Replace(".", "").ToPascalCase()); + + return schemaToNameMapCooked[definition]; } } } diff --git a/src/LibKubernetesGenerator/ClientSetGenerator.cs b/src/LibKubernetesGenerator/ClientSetGenerator.cs new file mode 100644 index 000000000..a0b392d8b --- /dev/null +++ b/src/LibKubernetesGenerator/ClientSetGenerator.cs @@ -0,0 +1,103 @@ +using CaseExtensions; +using Microsoft.CodeAnalysis; +using NSwag; +using System.Collections.Generic; +using System.Linq; + +namespace LibKubernetesGenerator +{ + internal class ClientSetGenerator + { + private readonly ScriptObjectFactory _scriptObjectFactory; + + public ClientSetGenerator(ScriptObjectFactory scriptObjectFactory) + { + _scriptObjectFactory = scriptObjectFactory; + } + + public void Generate(OpenApiDocument swagger, IncrementalGeneratorPostInitializationContext context) + { + var data = swagger.Operations + .Where(o => o.Method != OpenApiOperationMethod.Options) + .Select(o => + { + var ps = o.Operation.ActualParameters.OrderBy(p => !p.IsRequired).ToArray(); + + o.Operation.Parameters.Clear(); + + var name = new HashSet(); + + var i = 1; + foreach (var p in ps) + { + if (name.Contains(p.Name)) + { + p.Name += i++; + } + + o.Operation.Parameters.Add(p); + name.Add(p.Name); + } + + return o; + }) + .Select(o => + { + o.Path = o.Path.TrimStart('/'); + o.Method = char.ToUpper(o.Method[0]) + o.Method.Substring(1); + return o; + }) + .ToArray(); + + var sc = _scriptObjectFactory.CreateScriptObject(); + + var groups = new List(); + var apiGroups = new Dictionary(); + + foreach (var grouped in data.Where(d => HasKubernetesAction(d.Operation?.ExtensionData)) + .GroupBy(d => d.Operation.Tags.First())) + { + var clients = new List(); + var name = grouped.Key.ToPascalCase(); + groups.Add(name); + var apis = grouped.Select(x => + { + var groupVersionKindElements = x.Operation?.ExtensionData?["x-kubernetes-group-version-kind"]; + var groupVersionKind = (Dictionary)groupVersionKindElements; + + return new { Kind = groupVersionKind?["kind"] as string, Api = x }; + }); + + foreach (var item in apis.GroupBy(x => x.Kind)) + { + var kind = item.Key; + apiGroups[kind] = item.Select(x => x.Api).ToArray(); + clients.Add(kind); + } + + sc.SetValue("clients", clients, true); + sc.SetValue("name", name, true); + context.RenderToContext("GroupClient.cs.template", sc, $"{name}GroupClient.g.cs"); + } + + foreach (var apiGroup in apiGroups) + { + var name = apiGroup.Key; + var apis = apiGroup.Value.ToArray(); + var group = apis.Select(x => x.Operation.Tags[0]).First(); + sc.SetValue("apis", apis, true); + sc.SetValue("name", name, true); + sc.SetValue("group", group.ToPascalCase(), true); + context.RenderToContext("Client.cs.template", sc, $"{name}Client.g.cs"); + } + + sc = _scriptObjectFactory.CreateScriptObject(); + sc.SetValue("groups", groups, true); + + context.RenderToContext("ClientSet.cs.template", sc, $"ClientSet.g.cs"); + } + + private bool HasKubernetesAction(IDictionary extensionData) => + extensionData?.ContainsKey("x-kubernetes-action") ?? false; + } +} diff --git a/src/LibKubernetesGenerator/EmbedResource.cs b/src/LibKubernetesGenerator/EmbedResource.cs new file mode 100644 index 000000000..85a6dda86 --- /dev/null +++ b/src/LibKubernetesGenerator/EmbedResource.cs @@ -0,0 +1,18 @@ +using System.IO; +using System.Reflection; + +namespace LibKubernetesGenerator; + +internal static class EmbedResource +{ + public static string GetResource(string name) + { + var assembly = Assembly.GetExecutingAssembly(); + + var resourceName = assembly.GetName().Name + "." + name; + + using var stream = assembly.GetManifestResourceStream(resourceName); + using var reader = new StreamReader(stream ?? throw new FileNotFoundException(resourceName)); + return reader.ReadToEnd(); + } +} diff --git a/src/LibKubernetesGenerator/GeneralNameHelper.cs b/src/LibKubernetesGenerator/GeneralNameHelper.cs index b34b7dcb2..2d4f646f7 100644 --- a/src/LibKubernetesGenerator/GeneralNameHelper.cs +++ b/src/LibKubernetesGenerator/GeneralNameHelper.cs @@ -1,14 +1,15 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text.RegularExpressions; using CaseExtensions; using NJsonSchema; using NSwag; -using Nustache.Core; +using Scriban.Runtime; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; namespace LibKubernetesGenerator { - internal class GeneralNameHelper : INustacheHelper + internal class GeneralNameHelper : IScriptObjectHelper { private readonly ClassNameHelper classNameHelper; @@ -17,20 +18,13 @@ public GeneralNameHelper(ClassNameHelper classNameHelper) this.classNameHelper = classNameHelper; } - public void RegisterHelper() - { - Helpers.Register(nameof(GetInterfaceName), GetInterfaceName); - Helpers.Register(nameof(GetMethodName), GetMethodName); - Helpers.Register(nameof(GetDotNetName), GetDotNetName); - } - - public void GetInterfaceName(RenderContext context, IList arguments, - IDictionary options, RenderBlock fn, RenderBlock inverse) + public void RegisterHelper(ScriptObject scriptObject) { - if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is JsonSchema) - { - context.Write(GetInterfaceName(arguments[0] as JsonSchema)); - } + scriptObject.Import(nameof(GetInterfaceName), new Func(GetInterfaceName)); + scriptObject.Import(nameof(GetOperationId), new Func(GetOperationId)); + scriptObject.Import(nameof(GetActionName), new Func(GetActionName)); + scriptObject.Import(nameof(GetDotNetName), new Func(GetDotNetName)); + scriptObject.Import(nameof(GetDotNetNameOpenApiParameter), new Func(GetDotNetNameOpenApiParameter)); } private string GetInterfaceName(JsonSchema definition) @@ -63,49 +57,19 @@ private string GetInterfaceName(JsonSchema definition) } } - interfaces.Add("IValidate"); - return string.Join(", ", interfaces); } - public void GetMethodName(RenderContext context, IList arguments, IDictionary options, - RenderBlock fn, RenderBlock inverse) + public string GetDotNetNameOpenApiParameter(OpenApiParameter parameter, string init) { - if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is OpenApiOperation) - { - string suffix = null; - if (arguments.Count > 1) - { - suffix = arguments[1] as string; - } - - context.Write(GetMethodName(arguments[0] as OpenApiOperation, suffix)); - } - } + var name = GetDotNetName(parameter.Name); - public void GetDotNetName(RenderContext context, IList arguments, IDictionary options, - RenderBlock fn, RenderBlock inverse) - { - if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is OpenApiParameter) + if (init == "true" && !parameter.IsRequired) { - var parameter = arguments[0] as OpenApiParameter; - context.Write(GetDotNetName(parameter.Name)); - - if (arguments.Count > 1 && arguments[1] as string == "true" && !parameter.IsRequired) - { - context.Write(" = null"); - } + name += " = default"; } - else if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is string) - { - var style = "parameter"; - if (arguments.Count > 1) - { - style = arguments[1] as string; - } - context.Write(GetDotNetName((string)arguments[0], style)); - } + return name; } public string GetDotNetName(string jsonName, string style = "parameter") @@ -113,57 +77,51 @@ public string GetDotNetName(string jsonName, string style = "parameter") switch (style) { case "parameter": - if (jsonName == "namespace") - { - return "namespaceParameter"; - } - else if (jsonName == "continue") + switch (jsonName) { - return "continueParameter"; + case "namespace": + return "namespaceParameter"; + case "continue": + return "continueParameter"; + default: + break; } break; case "fieldctor": - if (jsonName == "namespace") - { - return "namespaceProperty"; - } - else if (jsonName == "continue") - { - return "continueProperty"; - } - else if (jsonName == "$ref") - { - return "refProperty"; - } - else if (jsonName == "default") - { - return "defaultProperty"; - } - else if (jsonName == "operator") - { - return "operatorProperty"; - } - else if (jsonName == "$schema") - { - return "schema"; - } - else if (jsonName == "enum") - { - return "enumProperty"; - } - else if (jsonName == "object") - { - return "objectProperty"; - } - else if (jsonName == "readOnly") - { - return "readOnlyProperty"; - } - else if (jsonName == "from") + + switch (jsonName) { - return "fromProperty"; + case "namespace": + return "namespaceProperty"; + case "continue": + return "continueProperty"; + case "$ref": + return "refProperty"; + case "default": + return "defaultProperty"; + case "operator": + return "operatorProperty"; + case "$schema": + return "schema"; + case "enum": + return "enumProperty"; + case "object": + return "objectProperty"; + case "readOnly": + return "readOnlyProperty"; + case "from": + return "fromProperty"; + case "int": + return "intValue"; + case "bool": + return "boolValue"; + case "string": + return "stringValue"; + + default: + break; } if (jsonName.Contains("-")) @@ -179,7 +137,7 @@ public string GetDotNetName(string jsonName, string style = "parameter") return jsonName.ToCamelCase(); } - public static string GetMethodName(OpenApiOperation watchOperation, string suffix) + public static string GetOperationId(OpenApiOperation watchOperation, string suffix) { var tag = watchOperation.Tags[0]; tag = tag.Replace("_", string.Empty); @@ -203,5 +161,28 @@ public static string GetMethodName(OpenApiOperation watchOperation, string suffi return methodName; } + + public static string GetActionName(OpenApiOperation apiOperation, string resource, string suffix) + { + var operationId = apiOperation.OperationId.ToPascalCase(); + var replacements = new Dictionary(StringComparer.OrdinalIgnoreCase) + { + { "Replace", "Update" }, + { "Read", "Get" }, + }; + + foreach (var replacement in replacements) + { + operationId = Regex.Replace(operationId, replacement.Key, replacement.Value, RegexOptions.IgnoreCase); + } + + var resources = new[] { resource, "ForAllNamespaces", "Namespaced" }; + var pattern = string.Join("|", Array.ConvertAll(resources, Regex.Escape)); + var actionName = pattern.Length > 0 + ? Regex.Replace(operationId, pattern, string.Empty, RegexOptions.IgnoreCase) + : operationId; + + return $"{actionName}{suffix}"; + } } } diff --git a/src/LibKubernetesGenerator/GeneratorExecutionContextExt.cs b/src/LibKubernetesGenerator/GeneratorExecutionContextExt.cs index 99bd6082f..6c3653721 100644 --- a/src/LibKubernetesGenerator/GeneratorExecutionContextExt.cs +++ b/src/LibKubernetesGenerator/GeneratorExecutionContextExt.cs @@ -1,18 +1,29 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Text; -using Nustache.Core; -using System.IO; +using Microsoft.CodeAnalysis.CSharp; +using Scriban; +using Scriban.Runtime; using System.Text; namespace LibKubernetesGenerator { internal static class GeneratorExecutionContextExt { - public static void RenderToContext(this GeneratorExecutionContext context, string templatefile, object data, string generatedfile) + public static void RenderToContext(this IncrementalGeneratorPostInitializationContext context, string templatefile, ScriptObject sc, string generatedfile) { - context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.projectdir", out var root); - var generated = Render.FileToString(Path.Combine(root, "..", "LibKubernetesGenerator", "templates", templatefile), data); - context.AddSource(generatedfile, SourceText.From(generated, Encoding.UTF8)); + var tc = new TemplateContext(); + tc.PushGlobal(sc); + context.RenderToContext(templatefile, tc, generatedfile); + } + + public static void RenderToContext(this IncrementalGeneratorPostInitializationContext context, string templatefile, TemplateContext tc, string generatedfile) + { + var template = Template.Parse(EmbedResource.GetResource(templatefile)); + var generated = template.Render(tc); + + var syntaxTree = CSharpSyntaxTree.ParseText(generated); + var normalized = syntaxTree.GetRoot().NormalizeWhitespace().ToFullString(); + context.AddSource(generatedfile, SourceText.From(normalized, Encoding.UTF8)); } } } diff --git a/src/LibKubernetesGenerator/INustacheHelper.cs b/src/LibKubernetesGenerator/INustacheHelper.cs deleted file mode 100644 index c5593a809..000000000 --- a/src/LibKubernetesGenerator/INustacheHelper.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace LibKubernetesGenerator -{ - public interface INustacheHelper - { - void RegisterHelper(); - } -} diff --git a/src/LibKubernetesGenerator/IScriptObjectHelper.cs b/src/LibKubernetesGenerator/IScriptObjectHelper.cs new file mode 100644 index 000000000..99dc9fe77 --- /dev/null +++ b/src/LibKubernetesGenerator/IScriptObjectHelper.cs @@ -0,0 +1,8 @@ +using Scriban.Runtime; + +namespace LibKubernetesGenerator; + +internal interface IScriptObjectHelper +{ + void RegisterHelper(ScriptObject scriptObject); +} diff --git a/src/LibKubernetesGenerator/KubernetesClientSourceGenerator.cs b/src/LibKubernetesGenerator/KubernetesClientSourceGenerator.cs index 325e83cba..fd2713260 100644 --- a/src/LibKubernetesGenerator/KubernetesClientSourceGenerator.cs +++ b/src/LibKubernetesGenerator/KubernetesClientSourceGenerator.cs @@ -1,141 +1,88 @@ using Autofac; using Microsoft.CodeAnalysis; using NSwag; -using Nustache.Core; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; namespace LibKubernetesGenerator { [Generator] - public class KubernetesClientSourceGenerator : ISourceGenerator + public class KubernetesClientSourceGenerator : IIncrementalGenerator { - private static object execlock = new object(); - - public void ExecuteInner(GeneratorExecutionContext context) + private static (OpenApiDocument, IContainer) BuildContainer() { - lock (execlock) - { - var swaggerfile = context.AdditionalFiles.First(f => f.Path.EndsWith("swagger.json")); - var swagger = OpenApiDocument.FromJsonAsync(swaggerfile.GetText().ToString()).GetAwaiter().GetResult(); - - context.AnalyzerConfigOptions.GetOptions(swaggerfile).TryGetValue("build_metadata.AdditionalFiles.Generator", out var generatorSetting); - var generators = new HashSet(generatorSetting.Split(',')); - - var builder = new ContainerBuilder(); - - builder.RegisterType() - .WithParameter(new NamedParameter(nameof(swagger), swagger)) - .AsSelf() - .AsImplementedInterfaces() - ; - - builder.RegisterType() - .AsImplementedInterfaces() - ; - - builder.RegisterType() - .AsImplementedInterfaces() - ; - - builder.RegisterType() - .WithParameter(new TypedParameter(typeof(OpenApiDocument), swagger)) - .AsImplementedInterfaces() - ; - - builder.RegisterType() - .AsSelf() - .AsImplementedInterfaces() - ; - - builder.RegisterType() - .AsSelf() - .AsImplementedInterfaces() - ; - - builder.RegisterType() - .AsImplementedInterfaces() - ; - - builder.RegisterType() - .AsImplementedInterfaces() - ; - - builder.RegisterType(); - builder.RegisterType(); - builder.RegisterType(); - builder.RegisterType(); - builder.RegisterType(); - - var container = builder.Build(); - // TODO move to Handlebars.Net - { - var ch = typeof(Helpers).GetField("CustomHelpers", BindingFlags.Static | BindingFlags.NonPublic); - ((Dictionary)ch.GetValue(null)).Clear(); - } - - foreach (var helper in container.Resolve>()) - { - helper.RegisterHelper(); - } - - - if (generators.Contains("api")) - { - container.Resolve().Generate(swagger, context); - } - - if (generators.Contains("model")) - { - container.Resolve().Generate(swagger, context); - } - - if (generators.Contains("modelext")) - { - container.Resolve().Generate(swagger, context); - } - - if (generators.Contains("versionconverter")) - { - container.Resolve().Generate(swagger, context); - } - - if (generators.Contains("version")) - { - container.Resolve().Generate(swagger, context); - } - } + var swagger = OpenApiDocument.FromJsonAsync(EmbedResource.GetResource("swagger.json")).GetAwaiter().GetResult(); + var container = BuildContainer(swagger); + return (swagger, container); } - public void Execute(GeneratorExecutionContext context) + private static IContainer BuildContainer(OpenApiDocument swagger) { - try - { - ExecuteInner(context); - } - catch (Exception e) - { - context.ReportDiagnostic(Diagnostic.Create( - new DiagnosticDescriptor( - "K8SCSG01", - e.Message, - e.StackTrace, - "Kubernetes C# code generator", - DiagnosticSeverity.Error, - true), Location.None)); - } + var builder = new ContainerBuilder(); + + builder.RegisterType() + .WithParameter(new NamedParameter(nameof(swagger), swagger)) + .AsSelf() + .AsImplementedInterfaces() + ; + + builder.RegisterType() + .AsImplementedInterfaces() + ; + + builder.RegisterType() + .AsImplementedInterfaces() + ; + + builder.RegisterType() + .WithParameter(new TypedParameter(typeof(OpenApiDocument), swagger)) + .AsImplementedInterfaces() + ; + + builder.RegisterType() + .AsSelf() + .AsImplementedInterfaces() + ; + + builder.RegisterType() + .AsSelf() + .AsImplementedInterfaces() + ; + + builder.RegisterType() + .AsImplementedInterfaces() + ; + + builder.RegisterType() + .AsImplementedInterfaces() + ; + + builder.RegisterType() + ; + + builder.RegisterType(); + builder.RegisterType(); + builder.RegisterType(); + builder.RegisterType(); + builder.RegisterType(); + + return builder.Build(); } - public void Initialize(GeneratorInitializationContext context) + public void Initialize(IncrementalGeneratorInitializationContext generatorContext) { -#if DEBUG - // if (!Debugger.IsAttached) - // { - // Debugger.Launch(); - // } +#if GENERATE_BASIC + generatorContext.RegisterPostInitializationOutput(ctx => + { + var (swagger, container) = BuildContainer(); + + container.Resolve().Generate(swagger, ctx); + + container.Resolve().Generate(swagger, ctx); + container.Resolve().Generate(swagger, ctx); + container.Resolve().Generate(swagger, ctx); + container.Resolve().Generate(swagger, ctx); + }); #endif - } + + } } } diff --git a/src/LibKubernetesGenerator/LibKubernetesGenerator.csproj b/src/LibKubernetesGenerator/LibKubernetesGenerator.target similarity index 51% rename from src/LibKubernetesGenerator/LibKubernetesGenerator.csproj rename to src/LibKubernetesGenerator/LibKubernetesGenerator.target index 08de6bac4..80a9cd252 100644 --- a/src/LibKubernetesGenerator/LibKubernetesGenerator.csproj +++ b/src/LibKubernetesGenerator/LibKubernetesGenerator.target @@ -1,24 +1,41 @@ - + netstandard2.0 - CA1812 + true + true - - + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -27,15 +44,18 @@ - + + + + + - - + - + diff --git a/src/LibKubernetesGenerator/MetaHelper.cs b/src/LibKubernetesGenerator/MetaHelper.cs index 5cc701319..72fdb462e 100644 --- a/src/LibKubernetesGenerator/MetaHelper.cs +++ b/src/LibKubernetesGenerator/MetaHelper.cs @@ -1,28 +1,19 @@ -using System; -using System.Collections.Generic; using NJsonSchema; using NSwag; -using Nustache.Core; +using Scriban.Runtime; +using System; +using System.Collections.Generic; namespace LibKubernetesGenerator { - internal class MetaHelper : INustacheHelper + internal class MetaHelper : IScriptObjectHelper { - public void RegisterHelper() - { - Helpers.Register(nameof(GetGroup), GetGroup); - Helpers.Register(nameof(GetApiVersion), GetApiVersion); - Helpers.Register(nameof(GetKind), GetKind); - Helpers.Register(nameof(GetPathExpression), GetPathExpression); - } - - public static void GetKind(RenderContext context, IList arguments, IDictionary options, - RenderBlock fn, RenderBlock inverse) + public void RegisterHelper(ScriptObject scriptObject) { - if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is JsonSchema) - { - context.Write(GetKind(arguments[0] as JsonSchema)); - } + scriptObject.Import(nameof(GetGroup), GetGroup); + scriptObject.Import(nameof(GetApiVersion), GetApiVersion); + scriptObject.Import(nameof(GetKind), GetKind); + scriptObject.Import(nameof(GetPathExpression), GetPathExpression); } private static string GetKind(JsonSchema definition) @@ -33,15 +24,6 @@ private static string GetKind(JsonSchema definition) return groupVersionKind["kind"] as string; } - public static void GetGroup(RenderContext context, IList arguments, IDictionary options, - RenderBlock fn, RenderBlock inverse) - { - if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is JsonSchema) - { - context.Write(GetGroup(arguments[0] as JsonSchema)); - } - } - private static string GetGroup(JsonSchema definition) { var groupVersionKindElements = (object[])definition.ExtensionData["x-kubernetes-group-version-kind"]; @@ -50,16 +32,6 @@ private static string GetGroup(JsonSchema definition) return groupVersionKind["group"] as string; } - public static void GetApiVersion(RenderContext context, IList arguments, - IDictionary options, - RenderBlock fn, RenderBlock inverse) - { - if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is JsonSchema) - { - context.Write(GetApiVersion(arguments[0] as JsonSchema)); - } - } - private static string GetApiVersion(JsonSchema definition) { var groupVersionKindElements = (object[])definition.ExtensionData["x-kubernetes-group-version-kind"]; @@ -68,17 +40,6 @@ private static string GetApiVersion(JsonSchema definition) return groupVersionKind["version"] as string; } - public static void GetPathExpression(RenderContext context, IList arguments, - IDictionary options, RenderBlock fn, RenderBlock inverse) - { - if (arguments != null && arguments.Count > 0 && arguments[0] != null && - arguments[0] is OpenApiOperationDescription) - { - var operation = arguments[0] as OpenApiOperationDescription; - context.Write(GetPathExpression(operation)); - } - } - private static string GetPathExpression(OpenApiOperationDescription operation) { var pathExpression = operation.Path; diff --git a/src/LibKubernetesGenerator/ModelExtGenerator.cs b/src/LibKubernetesGenerator/ModelExtGenerator.cs deleted file mode 100644 index 13d942d00..000000000 --- a/src/LibKubernetesGenerator/ModelExtGenerator.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Microsoft.CodeAnalysis; -using NSwag; - -namespace LibKubernetesGenerator -{ - internal class ModelExtGenerator - { - private readonly ClassNameHelper classNameHelper; - - public ModelExtGenerator(ClassNameHelper classNameHelper) - { - this.classNameHelper = classNameHelper; - } - - public void Generate(OpenApiDocument swagger, GeneratorExecutionContext context) - { - // Generate the interface declarations - var skippedTypes = new HashSet { "V1WatchEvent" }; - - var definitions = swagger.Definitions.Values - .Where( - d => d.ExtensionData != null - && d.ExtensionData.ContainsKey("x-kubernetes-group-version-kind") - && !skippedTypes.Contains(classNameHelper.GetClassName(d))); - - context.RenderToContext("ModelExtensions.cs.template", definitions, "ModelExtensions.g.cs"); - } - } -} diff --git a/src/LibKubernetesGenerator/ModelGenerator.cs b/src/LibKubernetesGenerator/ModelGenerator.cs index 8c55a0db0..df9f8d3ea 100644 --- a/src/LibKubernetesGenerator/ModelGenerator.cs +++ b/src/LibKubernetesGenerator/ModelGenerator.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using Microsoft.CodeAnalysis; using NSwag; @@ -6,22 +7,63 @@ namespace LibKubernetesGenerator internal class ModelGenerator { private readonly ClassNameHelper classNameHelper; + private readonly ScriptObjectFactory scriptObjectFactory; - public ModelGenerator(ClassNameHelper classNameHelper) + public ModelGenerator(ClassNameHelper classNameHelper, ScriptObjectFactory scriptObjectFactory) { this.classNameHelper = classNameHelper; + this.scriptObjectFactory = scriptObjectFactory; } - public void Generate(OpenApiDocument swagger, GeneratorExecutionContext context) + public void Generate(OpenApiDocument swagger, IncrementalGeneratorPostInitializationContext context) { + var sc = scriptObjectFactory.CreateScriptObject(); + + var genSkippedTypes = new HashSet + { + "IntOrString", + "ResourceQuantity", + "V1Patch", + }; + + var extSkippedTypes = new HashSet + { + "V1WatchEvent", + }; + + var typeOverrides = new Dictionary + { + // not used at the moment + }; + foreach (var kv in swagger.Definitions) { var def = kv.Value; var clz = classNameHelper.GetClassNameForSchemaDefinition(def); - context.RenderToContext( - "Model.cs.template", - new { clz, def, properties = def.Properties.Values }, - $"Models_{clz}.g.cs"); + + if (genSkippedTypes.Contains(clz)) + { + continue; + } + + var hasExt = def.ExtensionData != null + && def.ExtensionData.ContainsKey("x-kubernetes-group-version-kind") + && !extSkippedTypes.Contains(clz); + + + var typ = "record"; + if (typeOverrides.TryGetValue(clz, out var to)) + { + typ = to; + } + + sc.SetValue("clz", clz, true); + sc.SetValue("def", def, true); + sc.SetValue("properties", def.Properties.Values, true); + sc.SetValue("typ", typ, true); + sc.SetValue("hasExt", hasExt, true); + + context.RenderToContext("Model.cs.template", sc, $"Models_{clz}.g.cs"); } } } diff --git a/src/LibKubernetesGenerator/ParamHelper.cs b/src/LibKubernetesGenerator/ParamHelper.cs index 35ad9325f..fcaf030d9 100644 --- a/src/LibKubernetesGenerator/ParamHelper.cs +++ b/src/LibKubernetesGenerator/ParamHelper.cs @@ -1,12 +1,13 @@ -using System.Collections.Generic; -using System.Linq; using NJsonSchema; using NSwag; -using Nustache.Core; +using Scriban.Runtime; +using System; +using System.Linq; +using System.Collections.Generic; namespace LibKubernetesGenerator { - internal class ParamHelper : INustacheHelper + internal class ParamHelper : IScriptObjectHelper { private readonly GeneralNameHelper generalNameHelper; private readonly TypeHelper typeHelper; @@ -17,84 +18,50 @@ public ParamHelper(GeneralNameHelper generalNameHelper, TypeHelper typeHelper) this.typeHelper = typeHelper; } - public void RegisterHelper() + public void RegisterHelper(ScriptObject scriptObject) { - Helpers.Register(nameof(IfParamContains), IfParamContains); - Helpers.Register(nameof(IfParamDoesNotContain), IfParamDoesNotContain); - Helpers.Register(nameof(GetModelCtorParam), GetModelCtorParam); + scriptObject.Import(nameof(GetModelCtorParam), new Func(GetModelCtorParam)); + scriptObject.Import(nameof(IfParamContains), IfParamContains); + scriptObject.Import(nameof(FilterParameters), FilterParameters); + scriptObject.Import(nameof(GetParameterValueForWatch), new Func(GetParameterValueForWatch)); } - public static void IfParamContains(RenderContext context, IList arguments, - IDictionary options, - RenderBlock fn, RenderBlock inverse) + public static bool IfParamContains(OpenApiOperation operation, string name) { - var operation = arguments?.FirstOrDefault() as OpenApiOperation; - if (operation != null) + var found = false; + + foreach (var param in operation.Parameters) { - string name = null; - if (arguments.Count > 1) + if (param.Name == name) { - name = arguments[1] as string; + found = true; + break; } + } - var found = false; - - foreach (var param in operation.Parameters) - { - if (param.Name == name) - { - found = true; - break; - } - } + return found; + } - if (found) - { - fn(null); - } - } + public static IEnumerable FilterParameters(OpenApiOperation operation, string excludeParam) + { + return operation.Parameters.Where(p => p.Name != excludeParam); } - public static void IfParamDoesNotContain(RenderContext context, IList arguments, - IDictionary options, - RenderBlock fn, RenderBlock inverse) + public string GetParameterValueForWatch(OpenApiParameter parameter, bool watch, string init = "false") { - var operation = arguments?.FirstOrDefault() as OpenApiOperation; - if (operation != null) + if (parameter.Name == "watch") { - string name = null; - if (arguments.Count > 1) - { - name = arguments[1] as string; - } - - var found = false; - - foreach (var param in operation.Parameters) - { - if (param.Name == name) - { - found = true; - break; - } - } - - if (!found) - { - fn(null); - } + return watch ? "true" : "false"; + } + else + { + return generalNameHelper.GetDotNetNameOpenApiParameter(parameter, init); } } - public void GetModelCtorParam(RenderContext context, IList arguments, - IDictionary options, - RenderBlock fn, RenderBlock inverse) + public string GetModelCtorParam(JsonSchema schema) { - var schema = arguments[0] as JsonSchema; - - if (schema != null) - { - context.Write(string.Join(", ", schema.Properties.Values + return string.Join(", ", schema.Properties.Values .OrderBy(p => !p.IsRequired) .Select(p => { @@ -107,8 +74,7 @@ public void GetModelCtorParam(RenderContext context, IList arguments, } return sp; - }))); - } + })); } } -} +} \ No newline at end of file diff --git a/src/LibKubernetesGenerator/PluralHelper.cs b/src/LibKubernetesGenerator/PluralHelper.cs index 4d48a3f39..81091f88c 100644 --- a/src/LibKubernetesGenerator/PluralHelper.cs +++ b/src/LibKubernetesGenerator/PluralHelper.cs @@ -1,21 +1,22 @@ +using NJsonSchema; +using NSwag; +using Scriban.Runtime; using System; using System.Collections.Generic; using System.Linq; -using NJsonSchema; -using NSwag; -using Nustache.Core; namespace LibKubernetesGenerator { - internal class PluralHelper : INustacheHelper + internal class PluralHelper : IScriptObjectHelper { private readonly Dictionary _classNameToPluralMap; private readonly ClassNameHelper classNameHelper; - private HashSet opblackList = new HashSet() - { + private readonly HashSet opblackList = + [ "listClusterCustomObject", "listNamespacedCustomObject", - }; + "listCustomObjectForAllNamespaces", + ]; public PluralHelper(ClassNameHelper classNameHelper, OpenApiDocument swagger) { @@ -23,26 +24,9 @@ public PluralHelper(ClassNameHelper classNameHelper, OpenApiDocument swagger) _classNameToPluralMap = InitClassNameToPluralMap(swagger); } - public void RegisterHelper() - { - Helpers.Register(nameof(GetPlural), GetPlural); - } - - public void GetPlural(RenderContext context, IList arguments, IDictionary options, - RenderBlock fn, RenderBlock inverse) + public void RegisterHelper(ScriptObject scriptObject) { - if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is JsonSchema) - { - var plural = GetPlural(arguments[0] as JsonSchema); - if (plural != null) - { - context.Write($"\"{plural}\""); - } - else - { - context.Write("null"); - } - } + scriptObject.Import(nameof(GetPlural), new Func(GetPlural)); } public string GetPlural(JsonSchema definition) diff --git a/src/LibKubernetesGenerator/ScriptObjectFactory.cs b/src/LibKubernetesGenerator/ScriptObjectFactory.cs new file mode 100644 index 000000000..9e2fcd608 --- /dev/null +++ b/src/LibKubernetesGenerator/ScriptObjectFactory.cs @@ -0,0 +1,26 @@ +using Scriban.Runtime; +using System.Collections.Generic; +using System.Linq; + +namespace LibKubernetesGenerator; + +internal class ScriptObjectFactory +{ + private readonly List scriptObjectHelpers; + + public ScriptObjectFactory(IEnumerable scriptObjectHelpers) + { + this.scriptObjectHelpers = scriptObjectHelpers.ToList(); + } + + public ScriptObject CreateScriptObject() + { + var scriptObject = new ScriptObject(); + foreach (var helper in scriptObjectHelpers) + { + helper.RegisterHelper(scriptObject); + } + + return scriptObject; + } +} diff --git a/src/LibKubernetesGenerator/SourceGenerationContextGenerator.cs b/src/LibKubernetesGenerator/SourceGenerationContextGenerator.cs new file mode 100644 index 000000000..c73c020a1 --- /dev/null +++ b/src/LibKubernetesGenerator/SourceGenerationContextGenerator.cs @@ -0,0 +1,24 @@ +using Microsoft.CodeAnalysis; +using NSwag; + +namespace LibKubernetesGenerator +{ + internal class SourceGenerationContextGenerator + { + private readonly ScriptObjectFactory scriptObjectFactory; + + public SourceGenerationContextGenerator(ScriptObjectFactory scriptObjectFactory) + { + this.scriptObjectFactory = scriptObjectFactory; + } + + public void Generate(OpenApiDocument swagger, IncrementalGeneratorPostInitializationContext context) + { + var definitions = swagger.Definitions.Values; + var sc = scriptObjectFactory.CreateScriptObject(); + sc.SetValue("definitions", definitions, true); + + context.RenderToContext("SourceGenerationContext.cs.template", sc, "SourceGenerationContext.g.cs"); + } + } +} diff --git a/src/LibKubernetesGenerator/StringHelpers.cs b/src/LibKubernetesGenerator/StringHelpers.cs index bba545bec..7fd50eac5 100644 --- a/src/LibKubernetesGenerator/StringHelpers.cs +++ b/src/LibKubernetesGenerator/StringHelpers.cs @@ -1,15 +1,16 @@ +using NJsonSchema; +using Scriban.Runtime; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Security; +using System.Text; using System.Text.RegularExpressions; -using NJsonSchema; -using Nustache.Core; namespace LibKubernetesGenerator { - internal class StringHelpers : INustacheHelper + internal class StringHelpers : IScriptObjectHelper { private readonly GeneralNameHelper generalNameHelper; @@ -18,42 +19,46 @@ public StringHelpers(GeneralNameHelper generalNameHelper) this.generalNameHelper = generalNameHelper; } - public void RegisterHelper() + public void RegisterHelper(ScriptObject scriptObject) { - Helpers.Register(nameof(ToXmlDoc), ToXmlDoc); - Helpers.Register(nameof(ToInterpolationPathString), ToInterpolationPathString); - Helpers.Register(nameof(IfGroupPathParamContainsGroup), IfGroupPathParamContainsGroup); + scriptObject.Import(nameof(ToXmlDoc), new Func(ToXmlDoc)); + scriptObject.Import(nameof(ToInterpolationPathString), ToInterpolationPathString); + scriptObject.Import(nameof(IfGroupPathParamContainsGroup), IfGroupPathParamContainsGroup); } - private void ToXmlDoc(RenderContext context, IList arguments, IDictionary options, - RenderBlock fn, RenderBlock inverse) + public static string ToXmlDoc(string arg) { - if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is string) + if (arg == null) { - var first = true; + return ""; + } + + var first = true; + var sb = new StringBuilder(); - using (var reader = new StringReader(arguments[0] as string)) + using (var reader = new StringReader(arg)) + { + string line = null; + while ((line = reader.ReadLine()) != null) { - string line = null; - while ((line = reader.ReadLine()) != null) + foreach (var wline in WordWrap(line, 80)) { - foreach (var wline in WordWrap(line, 80)) + if (!first) { - if (!first) - { - context.Write("\n"); - context.Write(" /// "); - } - else - { - first = false; - } - - context.Write(SecurityElement.Escape(wline)); + sb.Append("\n"); + sb.Append(" /// "); + } + else + { + first = false; } + + sb.Append(SecurityElement.Escape(wline)); } } } + + return sb.ToString(); } private static IEnumerable WordWrap(string text, int width) @@ -91,24 +96,14 @@ private static IEnumerable WordWrap(string text, int width) } } - public void ToInterpolationPathString(RenderContext context, IList arguments, IDictionary options, - RenderBlock fn, RenderBlock inverse) + public string ToInterpolationPathString(string arg) { - var p = arguments?.FirstOrDefault() as string; - if (p != null) - { - context.Write(Regex.Replace(p, "{(.+?)}", (m) => "{" + generalNameHelper.GetDotNetName(m.Groups[1].Value) + "}")); - } + return Regex.Replace(arg, "{(.+?)}", (m) => "{" + generalNameHelper.GetDotNetName(m.Groups[1].Value) + "}"); } - public void IfGroupPathParamContainsGroup(RenderContext context, IList arguments, IDictionary options, - RenderBlock fn, RenderBlock inverse) + public static bool IfGroupPathParamContainsGroup(string arg) { - var p = arguments?.FirstOrDefault() as string; - if (p?.StartsWith("apis/{group}") == true) - { - fn(null); - } + return arg.StartsWith("apis/{group}"); } } } diff --git a/src/LibKubernetesGenerator/TypeHelper.cs b/src/LibKubernetesGenerator/TypeHelper.cs index 133cf8ea9..db27dab97 100644 --- a/src/LibKubernetesGenerator/TypeHelper.cs +++ b/src/LibKubernetesGenerator/TypeHelper.cs @@ -1,13 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; using NJsonSchema; using NSwag; -using Nustache.Core; +using Scriban.Runtime; +using System; namespace LibKubernetesGenerator { - internal class TypeHelper : INustacheHelper + internal class TypeHelper : IScriptObjectHelper { private readonly ClassNameHelper classNameHelper; @@ -16,57 +14,13 @@ public TypeHelper(ClassNameHelper classNameHelper) this.classNameHelper = classNameHelper; } - public void RegisterHelper() + public void RegisterHelper(ScriptObject scriptObject) { - Helpers.Register(nameof(GetDotNetType), GetDotNetType); - Helpers.Register(nameof(GetReturnType), GetReturnType); - Helpers.Register(nameof(IfReturnType), IfReturnType); - Helpers.Register(nameof(IfType), IfType); - } - - public void GetDotNetType(RenderContext context, IList arguments, - IDictionary options, - RenderBlock fn, RenderBlock inverse) - { - if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is OpenApiParameter) - { - var parameter = arguments[0] as OpenApiParameter; - - if (parameter.Schema?.Reference != null) - { - context.Write(classNameHelper.GetClassNameForSchemaDefinition(parameter.Schema.Reference)); - } - else if (parameter.Schema != null) - { - context.Write(GetDotNetType(parameter.Schema.Type, parameter.Name, parameter.IsRequired, - parameter.Schema.Format)); - } - else - { - context.Write(GetDotNetType(parameter.Type, parameter.Name, parameter.IsRequired, - parameter.Format)); - } - } - else if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is JsonSchemaProperty) - { - var property = arguments[0] as JsonSchemaProperty; - context.Write(GetDotNetType(property)); - } - else if (arguments != null && arguments.Count > 2 && arguments[0] != null && arguments[1] != null && - arguments[2] != null && arguments[0] is JsonObjectType && arguments[1] is string && - arguments[2] is bool) - { - context.Write(GetDotNetType((JsonObjectType)arguments[0], (string)arguments[1], (bool)arguments[2], - (string)arguments[3])); - } - else if (arguments != null && arguments.Count > 0 && arguments[0] != null) - { - context.Write($"ERROR: Expected OpenApiParameter but got {arguments[0].GetType().FullName}"); - } - else - { - context.Write("ERROR: Expected a OpenApiParameter argument but got none."); - } + scriptObject.Import(nameof(GetDotNetType), new Func(GetDotNetType)); + scriptObject.Import(nameof(GetDotNetTypeOpenApiParameter), new Func(GetDotNetTypeOpenApiParameter)); + scriptObject.Import(nameof(GetReturnType), new Func(GetReturnType)); + scriptObject.Import(nameof(IfReturnType), new Func(IfReturnType)); + scriptObject.Import(nameof(IfType), new Func(IfType)); } private string GetDotNetType(JsonObjectType jsonType, string name, bool required, string format) @@ -129,6 +83,13 @@ private string GetDotNetType(JsonObjectType jsonType, string name, bool required case "byte": return "byte[]"; case "date-time": + + // eventTime is required but should be optional, see https://github.com/kubernetes-client/csharp/issues/1197 + if (name == "eventTime") + { + return "System.DateTime?"; + } + if (required) { return "System.DateTime"; @@ -161,7 +122,6 @@ private string GetDotNetType(JsonSchema schema, JsonSchemaProperty parent) return $"IDictionary"; } - if (schema?.Reference != null) { return classNameHelper.GetClassNameForSchemaDefinition(schema.Reference); @@ -197,20 +157,21 @@ public string GetDotNetType(JsonSchemaProperty p) return GetDotNetType(p.Type, p.Name, p.IsRequired, p.Format); } - public void GetReturnType(RenderContext context, IList arguments, - IDictionary options, - RenderBlock fn, RenderBlock inverse) + public string GetDotNetTypeOpenApiParameter(OpenApiParameter parameter) { - var operation = arguments?.FirstOrDefault() as OpenApiOperation; - if (operation != null) + if (parameter.Schema?.Reference != null) { - string style = null; - if (arguments.Count > 1) - { - style = arguments[1] as string; - } - - context.Write(GetReturnType(operation, style)); + return classNameHelper.GetClassNameForSchemaDefinition(parameter.Schema.Reference); + } + else if (parameter.Schema != null) + { + return (GetDotNetType(parameter.Schema.Type, parameter.Name, parameter.IsRequired, + parameter.Schema.Format)); + } + else + { + return (GetDotNetType(parameter.Type, parameter.Name, parameter.IsRequired, + parameter.Format)); } } @@ -283,62 +244,74 @@ string toType() } break; + case "T": + var itemType = TryGetItemTypeFromSchema(response); + if (itemType != null) + { + return itemType; + } + + break; + case "TList": + return t; } return t; } - public void IfReturnType(RenderContext context, IList arguments, - IDictionary options, - RenderBlock fn, RenderBlock inverse) + public bool IfReturnType(OpenApiOperation operation, string type) { - var operation = arguments?.FirstOrDefault() as OpenApiOperation; - if (operation != null) + var rt = GetReturnType(operation, "void"); + if (type == "any" && rt != "void") { - string type = null; - if (arguments.Count > 1) - { - type = arguments[1] as string; - } + return true; + } + else if (string.Equals(type, rt.ToLower(), StringComparison.OrdinalIgnoreCase)) + { + return true; + } + else if (type == "obj" && rt != "void" && rt != "Stream") + { + return true; + } - var rt = GetReturnType(operation, "void"); - if (type == "any" && rt != "void") - { - fn(null); - } - else if (string.Equals(type, rt.ToLower(), StringComparison.OrdinalIgnoreCase)) - { - fn(null); - } - else if (type == "obj" && rt != "void" && rt != "Stream") - { - fn(null); - } + return false; + } + + public static bool IfType(JsonSchemaProperty property, string type) + { + if (type == "object" && property.Reference != null && !property.IsArray && + property.AdditionalPropertiesSchema == null) + { + return true; + } + else if (type == "objectarray" && property.IsArray && property.Item?.Reference != null) + { + return true; } + + return false; } - public static void IfType(RenderContext context, IList arguments, IDictionary options, - RenderBlock fn, RenderBlock inverse) + private string TryGetItemTypeFromSchema(OpenApiResponse response) { - var property = arguments?.FirstOrDefault() as JsonSchemaProperty; - if (property != null) + var listSchema = response?.Schema?.Reference; + if (listSchema?.Properties?.TryGetValue("items", out var itemsProperty) != true) { - string type = null; - if (arguments.Count > 1) - { - type = arguments[1] as string; - } + return null; + } - if (type == "object" && property.Reference != null && !property.IsArray && - property.AdditionalPropertiesSchema == null) - { - fn(null); - } - else if (type == "objectarray" && property.IsArray && property.Item?.Reference != null) - { - fn(null); - } + if (itemsProperty.Reference != null) + { + return classNameHelper.GetClassNameForSchemaDefinition(itemsProperty.Reference); } + + if (itemsProperty.Item?.Reference != null) + { + return classNameHelper.GetClassNameForSchemaDefinition(itemsProperty.Item.Reference); + } + + return null; } } -} +} \ No newline at end of file diff --git a/src/LibKubernetesGenerator/UtilHelper.cs b/src/LibKubernetesGenerator/UtilHelper.cs index 17f96090e..e11e1acc0 100644 --- a/src/LibKubernetesGenerator/UtilHelper.cs +++ b/src/LibKubernetesGenerator/UtilHelper.cs @@ -1,50 +1,30 @@ -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; using NSwag; -using Nustache.Core; +using Scriban.Runtime; namespace LibKubernetesGenerator { - internal class UtilHelper : INustacheHelper + internal class UtilHelper : IScriptObjectHelper { - public void RegisterHelper() + public void RegisterHelper(ScriptObject scriptObject) { - Helpers.Register(nameof(IfKindIs), IfKindIs); - Helpers.Register(nameof(IfListNotEmpty), IfListNotEmpty); + scriptObject.Import(nameof(IfKindIs), IfKindIs); } - public static void IfKindIs(RenderContext context, IList arguments, IDictionary options, - RenderBlock fn, RenderBlock inverse) + public static bool IfKindIs(OpenApiParameter parameter, string kind) { - var parameter = arguments?.FirstOrDefault() as OpenApiParameter; if (parameter != null) { - string kind = null; - if (arguments.Count > 1) - { - kind = arguments[1] as string; - } - if (kind == "query" && parameter.Kind == OpenApiParameterKind.Query) { - fn(null); + return true; } else if (kind == "path" && parameter.Kind == OpenApiParameterKind.Path) { - fn(null); + return true; } } - } - public static void IfListNotEmpty(RenderContext context, IList arguments, IDictionary options, - RenderBlock fn, RenderBlock inverse) - { - var parameter = arguments?.FirstOrDefault() as ObservableCollection; - if (parameter?.Any() == true) - { - fn(null); - } + return false; } } } diff --git a/src/LibKubernetesGenerator/VersionConverterGenerator.cs b/src/LibKubernetesGenerator/VersionConverterGenerator.cs deleted file mode 100644 index d049e7b1c..000000000 --- a/src/LibKubernetesGenerator/VersionConverterGenerator.cs +++ /dev/null @@ -1,117 +0,0 @@ -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Text; -using NSwag; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; - -namespace LibKubernetesGenerator -{ - internal class VersionConverterGenerator - { - private readonly ClassNameHelper classNameHelper; - - public VersionConverterGenerator(ClassNameHelper classNameHelper) - { - this.classNameHelper = classNameHelper; - } - - public void Generate(OpenApiDocument swagger, GeneratorExecutionContext context) - { - var allGeneratedModelClassNames = new List(); - - foreach (var kv in swagger.Definitions) - { - var def = kv.Value; - var clz = classNameHelper.GetClassNameForSchemaDefinition(def); - allGeneratedModelClassNames.Add(clz); - } - - var manualMaps = new List<(string, string)>(); - - var manualconverter = context.Compilation.SyntaxTrees.First(s => PathSuffixMath(s.FilePath, "Versioning/VersionConverter.cs")); - manualMaps = Regex.Matches(manualconverter.GetText().ToString(), @"\.CreateMap<(?.+?),\s?(?.+?)>") - .OfType() - .Select(x => (x.Groups["T1"].Value, x.Groups["T2"].Value)) - .ToList(); - - var versionRegex = @"(^V|v)[0-9]+((alpha|beta)[0-9]+)?"; - var typePairs = allGeneratedModelClassNames - .OrderBy(x => x) - .Select(x => new - { - Version = Regex.Match(x, versionRegex).Value?.ToLower(), - Kinda = Regex.Replace(x, versionRegex, string.Empty), - Type = x, - }) - .Where(x => !string.IsNullOrEmpty(x.Version)) - .GroupBy(x => x.Kinda) - .Where(x => x.Count() > 1) - .SelectMany(x => - x.SelectMany((value, index) => x.Skip(index + 1), (first, second) => new { first, second })) - .OrderBy(x => x.first.Kinda) - .ThenBy(x => x.first.Version) - .Select(x => (x.first.Type, x.second.Type)) - .ToList(); - - var versionConverterPairs = typePairs.Except(manualMaps).ToList(); - - var sbmodel = new StringBuilder(@"// -namespace k8s.Models; -using k8s.Versioning; -"); - - var sbversion = new StringBuilder(@"// -namespace k8s.Versioning; -using AutoMapper; -using k8s.Models; - - public static partial class VersionConverter - { - private static void AutoConfigurations(IMapperConfigurationExpression cfg) - { - -"); - - foreach (var (t0, t1) in versionConverterPairs) - { - sbmodel.AppendLine($@" - public partial class {t0} - {{ - public static explicit operator {t0}({t1} s) => VersionConverter.Mapper.Map<{t0}>(s); - }} - public partial class {t1} - {{ - public static explicit operator {t1}({t0} s) => VersionConverter.Mapper.Map<{t1}>(s); - }}"); - - sbversion.AppendLine($@"cfg.CreateMap<{t0}, {t1}>().ReverseMap();"); - } - - sbversion.AppendLine("}}"); - - context.AddSource($"ModelOperators.g.cs", SourceText.From(sbmodel.ToString(), Encoding.UTF8)); - context.AddSource($"VersionConverter.g.cs", SourceText.From(sbversion.ToString(), Encoding.UTF8)); - } - - private IEnumerable PathSplit(string path) - { - var p = path; - - while (!string.IsNullOrEmpty(p)) - { - yield return Path.GetFileName(p); - p = Path.GetDirectoryName(p); - } - } - - private bool PathSuffixMath(string path, string suffix) - { - var s = PathSplit(suffix).ToList(); - return PathSplit(path).Take(s.Count).SequenceEqual(s); - } - } -} diff --git a/src/LibKubernetesGenerator/VersionGenerator.cs b/src/LibKubernetesGenerator/VersionGenerator.cs index c1a196950..d621349ab 100644 --- a/src/LibKubernetesGenerator/VersionGenerator.cs +++ b/src/LibKubernetesGenerator/VersionGenerator.cs @@ -5,7 +5,7 @@ namespace LibKubernetesGenerator; internal class VersionGenerator { - public void Generate(OpenApiDocument swagger, GeneratorExecutionContext context) + public void Generate(OpenApiDocument swagger, IncrementalGeneratorPostInitializationContext context) { context.AddSource("k8sver.cs", $"// \n" + "internal static partial class ThisAssembly { internal const string KubernetesSwaggerVersion = \"" + swagger.Info.Version + "\";}"); } diff --git a/src/LibKubernetesGenerator/generators/LibKubernetesGenerator/LibKubernetesGenerator.csproj b/src/LibKubernetesGenerator/generators/LibKubernetesGenerator/LibKubernetesGenerator.csproj new file mode 100644 index 000000000..95f30efee --- /dev/null +++ b/src/LibKubernetesGenerator/generators/LibKubernetesGenerator/LibKubernetesGenerator.csproj @@ -0,0 +1,8 @@ + + + $(DefineConstants);GENERATE_BASIC; + + + + + diff --git a/src/LibKubernetesGenerator/templates/AbstractKubernetes.cs.template b/src/LibKubernetesGenerator/templates/AbstractKubernetes.cs.template index c2a0ad86b..94a607608 100644 --- a/src/LibKubernetesGenerator/templates/AbstractKubernetes.cs.template +++ b/src/LibKubernetesGenerator/templates/AbstractKubernetes.cs.template @@ -10,7 +10,7 @@ namespace k8s; /// public abstract partial class AbstractKubernetes { - {{#.}} - public I{{.}}Operations {{.}} => this; - {{/.}} -} + {{for group in groups}} + public I{{group}}Operations {{group}} => this; + {{end}} +} diff --git a/src/LibKubernetesGenerator/templates/Client.cs.template b/src/LibKubernetesGenerator/templates/Client.cs.template new file mode 100644 index 000000000..f9ce845e5 --- /dev/null +++ b/src/LibKubernetesGenerator/templates/Client.cs.template @@ -0,0 +1,165 @@ +// +// Code generated by https://github.com/kubernetes-client/csharp/tree/master/src/LibKubernetesGenerator +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// +using System.Net.Http; +using System.Net.Http.Headers; + +namespace k8s.ClientSets; + +/// +/// +public partial class {{name}}Client : ResourceClient +{ + public {{name}}Client(Kubernetes kubernetes) : base(kubernetes) + { + } + + {{for api in apis }} + {{~ $filteredParams = FilterParameters api.operation "watch" ~}} + /// + /// {{ToXmlDoc api.operation.description}} + /// + {{ for parameter in $filteredParams}} + /// + /// {{ToXmlDoc parameter.description}} + /// + {{end}} + /// + /// A which can be used to cancel the asynchronous operation. + /// + public async Task{{GetReturnType api.operation "<>"}} {{GetActionName api.operation name "Async"}}( + {{ for parameter in $filteredParams}} + {{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}}, + {{ end }} + CancellationToken cancellationToken = default(CancellationToken)) + { + {{if IfReturnType api.operation "stream"}} + var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}( + {{ for parameter in api.operation.parameters}} + {{GetParameterValueForWatch parameter false}}, + {{end}} + null, + cancellationToken); + _result.Request.Dispose(); + {{GetReturnType api.operation "_result.Body"}}; + {{end}} + {{if IfReturnType api.operation "obj"}} + using (var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}( + {{ for parameter in api.operation.parameters}} + {{GetParameterValueForWatch parameter false}}, + {{end}} + null, + cancellationToken).ConfigureAwait(false)) + { + {{GetReturnType api.operation "_result.Body"}}; + } + {{end}} + {{if IfReturnType api.operation "void"}} + using (var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}( + {{ for parameter in api.operation.parameters}} + {{GetParameterValueForWatch parameter false}}, + {{end}} + null, + cancellationToken).ConfigureAwait(false)) + { + } + {{end}} + } + + {{if IfReturnType api.operation "object"}} + /// + /// {{ToXmlDoc api.operation.description}} + /// + {{ for parameter in $filteredParams}} + /// + /// {{ToXmlDoc parameter.description}} + /// + {{end}} + /// + /// A which can be used to cancel the asynchronous operation. + /// + public async Task {{GetActionName api.operation name "Async"}}( + {{ for parameter in $filteredParams}} + {{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "false"}}, + {{ end }} + CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}( + {{ for parameter in api.operation.parameters}} + {{GetParameterValueForWatch parameter false}}, + {{end}} + null, + cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + {{end}} + +#if !K8S_AOT + {{if IfParamContains api.operation "watch"}} + /// + /// Watch {{ToXmlDoc api.operation.description}} + /// + {{ for parameter in $filteredParams}} + /// + /// {{ToXmlDoc parameter.description}} + /// + {{ end }} + /// Callback when any event raised from api server + /// Callback when any exception was caught during watching + /// Callback when the server closes the connection + public Watcher<{{GetReturnType api.operation "T"}}> Watch{{GetActionName api.operation name ""}}( + {{ for parameter in $filteredParams}} + {{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}}, + {{ end }} + Action onEvent = null, + Action onError = null, + Action onClosed = null) + { + if (onEvent == null) throw new ArgumentNullException(nameof(onEvent)); + + var responseTask = Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}( + {{ for parameter in api.operation.parameters}} + {{GetParameterValueForWatch parameter true}}, + {{ end }} + null, + CancellationToken.None); + + return responseTask.Watch<{{GetReturnType api.operation "T"}}, {{GetReturnType api.operation "TList"}}>( + onEvent, onError, onClosed); + } + + /// + /// Watch {{ToXmlDoc api.operation.description}} as async enumerable + /// + {{ for parameter in $filteredParams}} + /// + /// {{ToXmlDoc parameter.description}} + /// + {{ end }} + /// Callback when any exception was caught during watching + /// Cancellation token + public IAsyncEnumerable<(WatchEventType, {{GetReturnType api.operation "T"}})> Watch{{GetActionName api.operation name "Async"}}( + {{ for parameter in $filteredParams}} + {{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}}, + {{ end }} + Action onError = null, + CancellationToken cancellationToken = default) + { + var responseTask = Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}( + {{ for parameter in api.operation.parameters}} + {{GetParameterValueForWatch parameter true}}, + {{ end }} + null, + cancellationToken); + + return responseTask.WatchAsync<{{GetReturnType api.operation "T"}}, {{GetReturnType api.operation "TList"}}>( + onError, cancellationToken); + } + {{end}} +#endif + {{end}} +} \ No newline at end of file diff --git a/src/LibKubernetesGenerator/templates/ClientSet.cs.template b/src/LibKubernetesGenerator/templates/ClientSet.cs.template new file mode 100644 index 000000000..c358b2b3c --- /dev/null +++ b/src/LibKubernetesGenerator/templates/ClientSet.cs.template @@ -0,0 +1,16 @@ +// +// Code generated by https://github.com/kubernetes-client/csharp/tree/master/src/LibKubernetesGenerator +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace k8s.ClientSets; + +/// +/// +public partial class ClientSet +{ + {{for group in groups}} + public {{group}}GroupClient {{group}} => new {{group}}GroupClient(_kubernetes); + {{end}} +} diff --git a/src/LibKubernetesGenerator/templates/GroupClient.cs.template b/src/LibKubernetesGenerator/templates/GroupClient.cs.template new file mode 100644 index 000000000..45f219e55 --- /dev/null +++ b/src/LibKubernetesGenerator/templates/GroupClient.cs.template @@ -0,0 +1,24 @@ +// +// Code generated by https://github.com/kubernetes-client/csharp/tree/master/src/LibKubernetesGenerator +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace k8s.ClientSets; + + +/// +/// +public partial class {{name}}GroupClient +{ + private readonly Kubernetes _kubernetes; + + {{for client in clients}} + public {{client}}Client {{client}} => new {{client}}Client(_kubernetes); + {{end}} + + public {{name}}GroupClient(Kubernetes kubernetes) + { + _kubernetes = kubernetes; + } +} diff --git a/src/LibKubernetesGenerator/templates/IBasicKubernetes.cs.template b/src/LibKubernetesGenerator/templates/IKubernetes.cs.template similarity index 67% rename from src/LibKubernetesGenerator/templates/IBasicKubernetes.cs.template rename to src/LibKubernetesGenerator/templates/IKubernetes.cs.template index 9aa2c173c..68e92500d 100644 --- a/src/LibKubernetesGenerator/templates/IBasicKubernetes.cs.template +++ b/src/LibKubernetesGenerator/templates/IKubernetes.cs.template @@ -8,9 +8,9 @@ namespace k8s; /// /// -public partial interface IBasicKubernetes +public partial interface IKubernetes { - {{#.}} - I{{.}}Operations {{.}} { get; } - {{/.}} + {{for group in groups}} + I{{group}}Operations {{group}} { get; } + {{end}} } \ No newline at end of file diff --git a/src/LibKubernetesGenerator/templates/IOperations.cs.template b/src/LibKubernetesGenerator/templates/IOperations.cs.template index 594b92cb6..6904b8b91 100644 --- a/src/LibKubernetesGenerator/templates/IOperations.cs.template +++ b/src/LibKubernetesGenerator/templates/IOperations.cs.template @@ -10,27 +10,50 @@ namespace k8s; /// public partial interface I{{name}}Operations { - {{#apis}} + {{for api in apis }} /// - /// {{ToXmlDoc operation.description}} + /// {{ToXmlDoc api.operation.description}} /// - {{#operation.parameters}} - /// - /// {{ToXmlDoc description}} + {{ for parameter in api.operation.parameters}} + /// + /// {{ToXmlDoc parameter.description}} /// - {{/operation.parameters}} + {{ end }} /// /// The headers that will be added to request. /// /// /// A which can be used to cancel the asynchronous operation. /// - Task"}}> {{GetMethodName operation "WithHttpMessagesAsync"}}( -{{#operation.parameters}} - {{GetDotNetType .}} {{GetDotNetName . "true"}}, -{{/operation.parameters}} + Task"}}> {{GetOperationId api.operation "WithHttpMessagesAsync"}}( +{{ for parameter in api.operation.parameters}} + {{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}}, +{{ end }} IReadOnlyDictionary> customHeaders = null, CancellationToken cancellationToken = default); - {{/apis}} + {{if IfReturnType api.operation "object"}} + /// + /// {{ToXmlDoc api.operation.description}} + /// + {{ for parameter in api.operation.parameters}} + /// + /// {{ToXmlDoc parameter.description}} + /// + {{ end }} + /// + /// The headers that will be added to request. + /// + /// + /// A which can be used to cancel the asynchronous operation. + /// + Task> {{GetOperationId api.operation "WithHttpMessagesAsync"}}( +{{ for parameter in api.operation.parameters}} + {{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}}, +{{ end }} + IReadOnlyDictionary> customHeaders = null, + CancellationToken cancellationToken = default); + {{ end }} + + {{ end }} } diff --git a/src/LibKubernetesGenerator/templates/Model.cs.template b/src/LibKubernetesGenerator/templates/Model.cs.template index 836940db2..721709f1e 100644 --- a/src/LibKubernetesGenerator/templates/Model.cs.template +++ b/src/LibKubernetesGenerator/templates/Model.cs.template @@ -4,90 +4,29 @@ // regenerated. // -namespace k8s.Models +namespace k8s.Models; + +/// +/// {{ToXmlDoc def.description}} +/// +{{ if hasExt }} +[KubernetesEntity(Group=KubeGroup, Kind=KubeKind, ApiVersion=KubeApiVersion, PluralName=KubePluralName)] +{{ end }} +public partial {{typ}} {{clz}} {{ if hasExt }} : {{ GetInterfaceName def }} {{ end }} { + {{ if hasExt}} + public const string KubeApiVersion = "{{ GetApiVersion def }}"; + public const string KubeKind = "{{ GetKind def }}"; + public const string KubeGroup = "{{ GetGroup def }}"; + public const string KubePluralName = "{{ GetPlural def }}"; + {{ end }} + + {{ for property in properties }} /// - /// {{ToXmlDoc def.description}} + /// {{ToXmlDoc property.description}} /// - public partial class {{clz}} - { - /// - /// Initializes a new instance of the {{GetClassName def}} class. - /// - public {{clz}}() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the {{GetClassName def}} class. - /// - {{#properties}} - {{#isRequired}} - /// - /// {{ToXmlDoc description}} - /// - {{/isRequired}} - {{/properties}} - {{#properties}} - {{^isRequired}} - /// - /// {{ToXmlDoc description}} - /// - {{/isRequired}} - {{/properties}} - public {{clz}}({{GetModelCtorParam def}}) - { - {{#properties}} - {{GetDotNetName name "field"}} = {{GetDotNetName name "fieldctor"}}; - {{/properties}} - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - {{#properties}} - - /// - /// {{ToXmlDoc description}} - /// - [JsonPropertyName("{{name}}")] - public {{GetDotNetType .}} {{GetDotNetName name "field"}} { get; set; } - {{/properties}} - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - {{#properties}} - {{#IfType . "object"}} - {{#isRequired}} - if ({{GetDotNetName name "field"}} == null) - { - throw new ArgumentNullException("{{GetDotNetName name "field"}}"); - } - {{/isRequired}} - {{/IfType . "object"}} - {{/properties}} - {{#properties}} - {{#IfType . "object"}} - {{GetDotNetName name "field"}}?.Validate(); - {{/IfType . "object"}} - {{#IfType . "objectarray"}} - if ({{GetDotNetName name "field"}} != null){ - foreach(var obj in {{GetDotNetName name "field"}}) - { - obj.Validate(); - } - } - {{/IfType . "objectarray"}} - {{/properties}} - } - } + [JsonPropertyName("{{property.name}}")] + public {{ if property.IsRequired }} required {{ end }} {{GetDotNetType property}} {{GetDotNetName property.name "field"}} { get; set; } + {{ end }} } + diff --git a/src/LibKubernetesGenerator/templates/ModelExtensions.cs.template b/src/LibKubernetesGenerator/templates/ModelExtensions.cs.template deleted file mode 100644 index c0b4b0ac6..000000000 --- a/src/LibKubernetesGenerator/templates/ModelExtensions.cs.template +++ /dev/null @@ -1,18 +0,0 @@ -// -// Code generated by https://github.com/kubernetes-client/csharp/tree/master/src/LibKubernetesGenerator -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// -namespace k8s.Models -{ -{{#.}} - [KubernetesEntity(Group=KubeGroup, Kind=KubeKind, ApiVersion=KubeApiVersion, PluralName=KubePluralName)] - public partial class {{GetClassName . }} : {{GetInterfaceName . }} - { - public const string KubeApiVersion = "{{GetApiVersion . }}"; - public const string KubeKind = "{{GetKind . }}"; - public const string KubeGroup = "{{GetGroup . }}"; - public const string KubePluralName = {{GetPlural . }}; - } - -{{/.}} -} diff --git a/src/LibKubernetesGenerator/templates/Operations.cs.template b/src/LibKubernetesGenerator/templates/Operations.cs.template index 6e4088dab..d98337ada 100644 --- a/src/LibKubernetesGenerator/templates/Operations.cs.template +++ b/src/LibKubernetesGenerator/templates/Operations.cs.template @@ -7,80 +7,138 @@ namespace k8s; public partial class AbstractKubernetes : I{{name}}Operations -{ - {{#apis}} - /// - async Task"}}> I{{name}}Operations.{{GetMethodName operation "WithHttpMessagesAsync"}}( -{{#operation.parameters}} - {{GetDotNetType .}} {{GetDotNetName .}}, -{{/operation.parameters}} +{ + {{for api in apis }} + {{if IfReturnType api.operation "void"}} + private async Task I{{name}}Operations_{{GetOperationId api.operation "WithHttpMessagesAsync"}}( + {{end}} + {{if IfReturnType api.operation "obj"}} + private async Task> I{{name}}Operations_{{GetOperationId api.operation "WithHttpMessagesAsync"}}( + {{end}} + {{if IfReturnType api.operation "stream"}} + private async Task> I{{name}}Operations_{{GetOperationId api.operation "WithHttpMessagesAsync"}}( + {{end}} +{{ for parameter in api.operation.parameters}} + {{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "false"}}, +{{end}} IReadOnlyDictionary> customHeaders, CancellationToken cancellationToken) { - var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); + using var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); cts.CancelAfter(HttpClientTimeout); - {{#IfParamContains operation "watch"}} + {{if IfParamContains api.operation "watch"}} if (watch == true) { cts.CancelAfter(Timeout.InfiniteTimeSpan); } - {{/IfParamContains operation "watch"}} + {{end}} cancellationToken = cts.Token; - {{#operation.parameters}} - {{#isRequired}} - if ({{GetDotNetName name}} == null) + {{ for parameter in api.operation.parameters}} + {{ if parameter.IsRequired}} + if ({{GetDotNetName parameter.name}} == null) { - throw new ArgumentNullException("{{GetDotNetName name}}"); + throw new ArgumentNullException("{{GetDotNetName parameter.name}}"); } - {{/isRequired}} - {{/operation.parameters}} + {{end}} + {{end}} // Construct URL - var url = $"{{ToInterpolationPathString path}}"; - {{#IfGroupPathParamContainsGroup path}} + var url = $"{{ToInterpolationPathString api.path}}"; + {{if IfGroupPathParamContainsGroup api.path}} url = url.Replace("apis//", "api/"); - {{/IfGroupPathParamContainsGroup}} - {{#IfListNotEmpty operation.parameters}} + {{end}} + {{if (array.size api.operation.parameters) > 0}} var q = new QueryBuilder(); - {{#operation.parameters}} - {{#IfKindIs . "query"}} - q.Append("{{name}}", {{GetDotNetName name}}); - {{/IfKindIs . "query"}} - {{/operation.parameters}} + {{ for parameter in api.operation.parameters}} + {{if IfKindIs parameter "query"}} + q.Append("{{parameter.name}}", {{GetDotNetName parameter.name}}); + {{end}} + {{end}} url += q.ToString(); - {{/IfListNotEmpty operation.parameters}} + {{end}} // Create HTTP transport - var httpRequest = CreateRequest(url, HttpMethods.{{Method}}, customHeaders); - {{#IfParamContains operation "body"}} - var httpResponse = await SendRequest(body, httpRequest, cancellationToken); - {{/IfParamContains operation "body"}} - {{#IfParamDoesNotContain operation "body"}} - var httpResponse = await SendRequestRaw("", httpRequest, cancellationToken); - {{/IfParamDoesNotContain operation "body"}} + {{if IfParamContains api.operation "body"}} + var httpResponse = await SendRequest(url, HttpMethods.{{api.method}}, customHeaders, body, cancellationToken); + {{ else }} + var httpResponse = await SendRequest(url, HttpMethods.{{api.method}}, customHeaders, null, cancellationToken); + {{end}} // Create Result - {{#IfReturnType operation "void"}} + var httpRequest = httpResponse.RequestMessage; + {{if IfReturnType api.operation "void"}} HttpOperationResponse result = new HttpOperationResponse() { Request = httpRequest, Response = httpResponse }; - {{/IfReturnType operation "void"}} - {{#IfReturnType operation "obj"}} - var result = await CreateResultAsync{{GetReturnType operation "<>"}}(httpRequest, + {{end}} + {{if IfReturnType api.operation "obj"}} + var result = await CreateResultAsync( + httpRequest, httpResponse, - {{#IfParamContains operation "watch"}} + {{if IfParamContains api.operation "watch"}} watch, - {{/IfParamContains operation "watch"}} - {{#IfParamDoesNotContain operation "watch"}} + {{else}} false, - {{/IfParamDoesNotContain operation "watch"}} + {{end}} cancellationToken); - {{/IfReturnType operation "obj"}} - {{#IfReturnType operation "stream"}} - var result = new HttpOperationResponse{{GetReturnType operation "<>"}}() { + {{end}} + {{if IfReturnType api.operation "stream"}} + var result = new HttpOperationResponse() { Request = httpRequest, Response = httpResponse, Body = await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false) }; - {{/IfReturnType operation "stream"}} + {{end}} return result; } - {{/apis}} + + /// + async Task"}}> I{{name}}Operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}( +{{ for parameter in api.operation.parameters}} + {{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "false"}}, +{{end}} + IReadOnlyDictionary> customHeaders, + CancellationToken cancellationToken) + { + {{if IfReturnType api.operation "void"}} + return await I{{name}}Operations_{{GetOperationId api.operation "WithHttpMessagesAsync"}}( +{{ for parameter in api.operation.parameters}} + {{GetDotNetNameOpenApiParameter parameter "false"}}, +{{end}} + customHeaders, + cancellationToken).ConfigureAwait(false); + {{end}} + {{if IfReturnType api.operation "obj"}} + return await I{{name}}Operations_{{GetOperationId api.operation "WithHttpMessagesAsync"}}{{GetReturnType api.operation "<>"}}( +{{ for parameter in api.operation.parameters}} + {{GetDotNetNameOpenApiParameter parameter "false"}}, +{{end}} + customHeaders, + cancellationToken).ConfigureAwait(false); + {{end}} + {{if IfReturnType api.operation "stream"}} + return await I{{name}}Operations_{{GetOperationId api.operation "WithHttpMessagesAsync"}}( +{{ for parameter in api.operation.parameters}} + {{GetDotNetNameOpenApiParameter parameter "false"}}, +{{end}} + customHeaders, + cancellationToken).ConfigureAwait(false); + {{end}} + } + + {{if IfReturnType api.operation "object"}} + /// + async Task> I{{name}}Operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}( +{{ for parameter in api.operation.parameters}} + {{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "false"}}, +{{end}} + IReadOnlyDictionary> customHeaders, + CancellationToken cancellationToken) + { + return await I{{name}}Operations_{{GetOperationId api.operation "WithHttpMessagesAsync"}}( +{{ for parameter in api.operation.parameters}} + {{GetDotNetNameOpenApiParameter parameter "false"}}, +{{end}} + customHeaders, + cancellationToken).ConfigureAwait(false); + } + {{end}} + {{end}} } diff --git a/src/LibKubernetesGenerator/templates/OperationsExtensions.cs.template b/src/LibKubernetesGenerator/templates/OperationsExtensions.cs.template index 0374990af..7544d235d 100644 --- a/src/LibKubernetesGenerator/templates/OperationsExtensions.cs.template +++ b/src/LibKubernetesGenerator/templates/OperationsExtensions.cs.template @@ -11,86 +11,221 @@ namespace k8s; /// public static partial class {{name}}OperationsExtensions { - {{#apis}} + {{for api in apis }} + {{~ $filteredParams = FilterParameters api.operation "watch" ~}} /// - /// {{ToXmlDoc operation.description}} + /// {{ToXmlDoc api.operation.description}} /// /// /// The operations group for this extension method. /// - {{#operation.parameters}} - /// - /// {{ToXmlDoc description}} + {{ for parameter in $filteredParams}} + /// + /// {{ToXmlDoc parameter.description}} /// - {{/operation.parameters}} - public static {{GetReturnType operation "void"}} {{GetMethodName operation ""}}( + {{ end }} + public static {{GetReturnType api.operation "void"}} {{GetOperationId api.operation ""}}( this I{{name}}Operations operations -{{#operation.parameters}} - ,{{GetDotNetType .}} {{GetDotNetName . "true"}} -{{/operation.parameters}} +{{ for parameter in $filteredParams}} + ,{{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}} +{{end}} ) { - {{GetReturnType operation "return"}} operations.{{GetMethodName operation "Async"}}( -{{#operation.parameters}} - {{GetDotNetName .}}, -{{/operation.parameters}} + {{GetReturnType api.operation "return"}} operations.{{GetOperationId api.operation "Async"}}( +{{ for parameter in $filteredParams}} + {{GetDotNetNameOpenApiParameter parameter "false"}}, +{{end}} CancellationToken.None ).GetAwaiter().GetResult(); - } + } + + {{if IfReturnType api.operation "object"}} + /// + /// {{ToXmlDoc api.operation.description}} + /// + /// + /// The operations group for this extension method. + /// + {{ for parameter in $filteredParams}} + /// + /// {{ToXmlDoc parameter.description}} + /// + {{end}} + public static T {{GetOperationId api.operation ""}}( + this I{{name}}Operations operations +{{ for parameter in $filteredParams}} + ,{{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}} +{{end}} + ) + { + return operations.{{GetOperationId api.operation "Async"}}( +{{ for parameter in $filteredParams}} + {{GetDotNetNameOpenApiParameter parameter "false"}}, +{{end}} + CancellationToken.None + ).GetAwaiter().GetResult(); + } + {{end}} /// - /// {{ToXmlDoc operation.description}} + /// {{ToXmlDoc api.operation.description}} /// /// /// The operations group for this extension method. /// - {{#operation.parameters}} - /// - /// {{ToXmlDoc description}} + {{ for parameter in $filteredParams}} + /// + /// {{ToXmlDoc parameter.description}} /// - {{/operation.parameters}} + {{end}} /// /// A which can be used to cancel the asynchronous operation. /// - public static async Task{{GetReturnType operation "<>"}} {{GetMethodName operation "Async"}}( + public static async Task{{GetReturnType api.operation "<>"}} {{GetOperationId api.operation "Async"}}( this I{{name}}Operations operations, - {{#operation.parameters}} - {{GetDotNetType .}} {{GetDotNetName . "true"}}, - {{/operation.parameters}} +{{ for parameter in $filteredParams}} + {{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}}, +{{ end }} CancellationToken cancellationToken = default(CancellationToken)) { - {{#IfReturnType operation "stream"}} - var _result = await operations.{{GetMethodName operation "WithHttpMessagesAsync"}}( - {{#operation.parameters}} - {{GetDotNetName .}}, - {{/operation.parameters}} + {{if IfReturnType api.operation "stream"}} + var _result = await operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}( +{{ for parameter in api.operation.parameters}} + {{GetParameterValueForWatch parameter false}}, +{{end}} null, cancellationToken); _result.Request.Dispose(); - {{GetReturnType operation "_result.Body"}}; - {{/IfReturnType operation "stream"}} - {{#IfReturnType operation "obj"}} - using (var _result = await operations.{{GetMethodName operation "WithHttpMessagesAsync"}}( - {{#operation.parameters}} - {{GetDotNetName .}}, - {{/operation.parameters}} + {{GetReturnType api.operation "_result.Body"}}; + {{end}} + {{if IfReturnType api.operation "obj"}} + using (var _result = await operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}( +{{ for parameter in api.operation.parameters}} + {{GetParameterValueForWatch parameter false}}, +{{end}} null, cancellationToken).ConfigureAwait(false)) { - {{GetReturnType operation "_result.Body"}}; + {{GetReturnType api.operation "_result.Body"}}; } - {{/IfReturnType operation "obj"}} - {{#IfReturnType operation "void"}} - using (var _result = await operations.{{GetMethodName operation "WithHttpMessagesAsync"}}( - {{#operation.parameters}} - {{GetDotNetName .}}, - {{/operation.parameters}} + {{end}} + {{if IfReturnType api.operation "void"}} + using (var _result = await operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}( +{{ for parameter in api.operation.parameters}} + {{GetParameterValueForWatch parameter false}}, +{{end}} null, cancellationToken).ConfigureAwait(false)) { } - {{/IfReturnType operation "void"}} + {{end}} } - {{/apis}} + {{if IfReturnType api.operation "object"}} + /// + /// {{ToXmlDoc api.operation.description}} + /// + /// + /// The operations group for this extension method. + /// + {{ for parameter in $filteredParams}} + /// + /// {{ToXmlDoc parameter.description}} + /// + {{end}} + /// + /// A which can be used to cancel the asynchronous operation. + /// + public static async Task {{GetOperationId api.operation "Async"}}( + this I{{name}}Operations operations, +{{ for parameter in $filteredParams}} + {{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}}, +{{ end }} + CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}( +{{ for parameter in api.operation.parameters}} + {{GetParameterValueForWatch parameter false}}, +{{end}} + null, + cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + {{end}} + +#if !K8S_AOT +{{if IfParamContains api.operation "watch"}} +{{~ $filteredParams = FilterParameters api.operation "watch" ~}} +/// +/// Watch {{ToXmlDoc api.operation.description}} +/// +/// +/// The operations group for this extension method. +/// +{{ for parameter in $filteredParams}} +/// +/// {{ToXmlDoc parameter.description}} +/// +{{ end }} +/// Callback when any event raised from api server +/// Callback when any exception was caught during watching +/// Callback when the server closes the connection +public static Watcher<{{GetReturnType api.operation "T"}}> Watch{{GetOperationId api.operation ""}}( + this I{{name}}Operations operations, +{{ for parameter in $filteredParams}} + {{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}}, +{{end}} + Action onEvent = null, + Action onError = null, + Action onClosed = null) +{ + if (onEvent == null) throw new ArgumentNullException(nameof(onEvent)); + + var responseTask = operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}( +{{ for parameter in api.operation.parameters}} + {{GetParameterValueForWatch parameter true}}, +{{end}} + null, + CancellationToken.None); + + return responseTask.Watch<{{GetReturnType api.operation "T"}}, {{GetReturnType api.operation "TList"}}>( + onEvent, onError, onClosed); +} + +/// +/// Watch {{ToXmlDoc api.operation.description}} as async enumerable +/// +/// +/// The operations group for this extension method. +/// +{{ for parameter in $filteredParams}} +/// +/// {{ToXmlDoc parameter.description}} +/// +{{ end }} +/// Callback when any exception was caught during watching +/// Cancellation token +public static IAsyncEnumerable<(WatchEventType, {{GetReturnType api.operation "T"}})> Watch{{GetOperationId api.operation "Async"}}( + this I{{name}}Operations operations, +{{ for parameter in $filteredParams}} + {{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}}, +{{end}} + Action onError = null, + CancellationToken cancellationToken = default) +{ + var responseTask = operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}( +{{ for parameter in api.operation.parameters}} + {{GetParameterValueForWatch parameter true}}, +{{end}} + null, + cancellationToken); + + return responseTask.WatchAsync<{{GetReturnType api.operation "T"}}, {{GetReturnType api.operation "TList"}}>( + onError, cancellationToken); } +{{end}} +#endif + {{end}} +} \ No newline at end of file diff --git a/src/LibKubernetesGenerator/templates/SourceGenerationContext.cs.template b/src/LibKubernetesGenerator/templates/SourceGenerationContext.cs.template new file mode 100644 index 000000000..0a5113981 --- /dev/null +++ b/src/LibKubernetesGenerator/templates/SourceGenerationContext.cs.template @@ -0,0 +1,15 @@ +// +// Code generated by https://github.com/kubernetes-client/csharp/tree/master/src/LibKubernetesGenerator +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// +#if NET8_0_OR_GREATER +namespace k8s +{ + {{ for definition in definitions }} + [JsonSerializable(typeof({{ GetClassName definition }}))] + {{ end }} + public partial class SourceGenerationContext : JsonSerializerContext + { + } +} +#endif diff --git a/src/nuget.proj b/src/nuget.proj index fa0a58d58..1f4213256 100644 --- a/src/nuget.proj +++ b/src/nuget.proj @@ -1,8 +1,7 @@ - - + diff --git a/swagger.json b/swagger.json index 953c587f9..2cc381669 100644 --- a/swagger.json +++ b/swagger.json @@ -1,5 +1,94 @@ { "definitions": { + "v1.AuditAnnotation": { + "description": "AuditAnnotation describes how to produce an audit annotation for an API request.", + "properties": { + "key": { + "description": "key specifies the audit annotation key. The audit annotation keys of a ValidatingAdmissionPolicy must be unique. The key must be a qualified name ([A-Za-z0-9][-A-Za-z0-9_.]*) no more than 63 bytes in length.\n\nThe key is combined with the resource name of the ValidatingAdmissionPolicy to construct an audit annotation key: \"{ValidatingAdmissionPolicy name}/{key}\".\n\nIf an admission webhook uses the same resource name as this ValidatingAdmissionPolicy and the same audit annotation key, the annotation key will be identical. In this case, the first annotation written with the key will be included in the audit event and all subsequent annotations with the same key will be discarded.\n\nRequired.", + "type": "string" + }, + "valueExpression": { + "description": "valueExpression represents the expression which is evaluated by CEL to produce an audit annotation value. The expression must evaluate to either a string or null value. If the expression evaluates to a string, the audit annotation is included with the string value. If the expression evaluates to null or empty string the audit annotation will be omitted. The valueExpression may be no longer than 5kb in length. If the result of the valueExpression is more than 10kb in length, it will be truncated to 10kb.\n\nIf multiple ValidatingAdmissionPolicyBinding resources match an API request, then the valueExpression will be evaluated for each binding. All unique values produced by the valueExpressions will be joined together in a comma-separated list.\n\nRequired.", + "type": "string" + } + }, + "required": [ + "key", + "valueExpression" + ], + "type": "object" + }, + "v1.ExpressionWarning": { + "description": "ExpressionWarning is a warning information that targets a specific expression.", + "properties": { + "fieldRef": { + "description": "The path to the field that refers the expression. For example, the reference to the expression of the first item of validations is \"spec.validations[0].expression\"", + "type": "string" + }, + "warning": { + "description": "The content of type checking information in a human-readable form. Each line of the warning contains the type that the expression is checked against, followed by the type check error from the compiler.", + "type": "string" + } + }, + "required": [ + "fieldRef", + "warning" + ], + "type": "object" + }, + "v1.MatchCondition": { + "description": "MatchCondition represents a condition which must by fulfilled for a request to be sent to a webhook.", + "properties": { + "expression": { + "description": "Expression represents the expression which will be evaluated by CEL. Must evaluate to bool. CEL expressions have access to the contents of the AdmissionRequest and Authorizer, organized into CEL variables:\n\n'object' - The object from the incoming request. The value is null for DELETE requests. 'oldObject' - The existing object. The value is null for CREATE requests. 'request' - Attributes of the admission request(/pkg/apis/admission/types.go#AdmissionRequest). 'authorizer' - A CEL Authorizer. May be used to perform authorization checks for the principal (user or service account) of the request.\n See https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz\n'authorizer.requestResource' - A CEL ResourceCheck constructed from the 'authorizer' and configured with the\n request resource.\nDocumentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/\n\nRequired.", + "type": "string" + }, + "name": { + "description": "Name is an identifier for this match condition, used for strategic merging of MatchConditions, as well as providing an identifier for logging purposes. A good name should be descriptive of the associated expression. Name must be a qualified name consisting of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName', or 'my.name', or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]') with an optional DNS subdomain prefix and '/' (e.g. 'example.com/MyName')\n\nRequired.", + "type": "string" + } + }, + "required": [ + "name", + "expression" + ], + "type": "object" + }, + "v1.MatchResources": { + "description": "MatchResources decides whether to run the admission control policy on an object based on whether it meets the match criteria. The exclude rules take precedence over include rules (if a resource matches both, it is excluded)", + "properties": { + "excludeResourceRules": { + "description": "ExcludeResourceRules describes what operations on what resources/subresources the ValidatingAdmissionPolicy should not care about. The exclude rules take precedence over include rules (if a resource matches both, it is excluded)", + "items": { + "$ref": "#/definitions/v1.NamedRuleWithOperations" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "matchPolicy": { + "description": "matchPolicy defines how the \"MatchResources\" list is used to match incoming requests. Allowed values are \"Exact\" or \"Equivalent\".\n\n- Exact: match a request only if it exactly matches a specified rule. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, but \"rules\" only included `apiGroups:[\"apps\"], apiVersions:[\"v1\"], resources: [\"deployments\"]`, a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the ValidatingAdmissionPolicy.\n\n- Equivalent: match a request if modifies a resource listed in rules, even via another API group or version. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, and \"rules\" only included `apiGroups:[\"apps\"], apiVersions:[\"v1\"], resources: [\"deployments\"]`, a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the ValidatingAdmissionPolicy.\n\nDefaults to \"Equivalent\"", + "type": "string" + }, + "namespaceSelector": { + "$ref": "#/definitions/v1.LabelSelector", + "description": "NamespaceSelector decides whether to run the admission control policy on an object based on whether the namespace for that object matches the selector. If the object itself is a namespace, the matching is performed on object.metadata.labels. If the object is another cluster scoped resource, it never skips the policy.\n\nFor example, to run the webhook on any objects whose namespace is not associated with \"runlevel\" of \"0\" or \"1\"; you will set the selector as follows: \"namespaceSelector\": {\n \"matchExpressions\": [\n {\n \"key\": \"runlevel\",\n \"operator\": \"NotIn\",\n \"values\": [\n \"0\",\n \"1\"\n ]\n }\n ]\n}\n\nIf instead you want to only run the policy on any objects whose namespace is associated with the \"environment\" of \"prod\" or \"staging\"; you will set the selector as follows: \"namespaceSelector\": {\n \"matchExpressions\": [\n {\n \"key\": \"environment\",\n \"operator\": \"In\",\n \"values\": [\n \"prod\",\n \"staging\"\n ]\n }\n ]\n}\n\nSee https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ for more examples of label selectors.\n\nDefault to the empty LabelSelector, which matches everything." + }, + "objectSelector": { + "$ref": "#/definitions/v1.LabelSelector", + "description": "ObjectSelector decides whether to run the validation based on if the object has matching labels. objectSelector is evaluated against both the oldObject and newObject that would be sent to the cel validation, and is considered to match if either object matches the selector. A null object (oldObject in the case of create, or newObject in the case of delete) or an object that cannot have labels (like a DeploymentRollback or a PodProxyOptions object) is not considered to match. Use the object selector only if the webhook is opt-in, because end users may skip the admission webhook by setting the labels. Default to the empty LabelSelector, which matches everything." + }, + "resourceRules": { + "description": "ResourceRules describes what operations on what resources/subresources the ValidatingAdmissionPolicy matches. The policy cares about an operation if it matches _any_ Rule.", + "items": { + "$ref": "#/definitions/v1.NamedRuleWithOperations" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + } + }, + "type": "object", + "x-kubernetes-map-type": "atomic" + }, "v1.MutatingWebhook": { "description": "MutatingWebhook describes an admission webhook and the resources and operations it applies to.", "properties": { @@ -8,7 +97,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "clientConfig": { "$ref": "#/definitions/admissionregistration.v1.WebhookClientConfig", @@ -18,6 +108,19 @@ "description": "FailurePolicy defines how unrecognized errors from the admission endpoint are handled - allowed values are Ignore or Fail. Defaults to Fail.", "type": "string" }, + "matchConditions": { + "description": "MatchConditions is a list of conditions that must be met for a request to be sent to this webhook. Match conditions filter requests that have already been matched by the rules, namespaceSelector, and objectSelector. An empty list of matchConditions matches all requests. There are a maximum of 64 match conditions allowed.\n\nThe exact matching logic is (in order):\n 1. If ANY matchCondition evaluates to FALSE, the webhook is skipped.\n 2. If ALL matchConditions evaluate to TRUE, the webhook is called.\n 3. If any matchCondition evaluates to an error (but none are FALSE):\n - If failurePolicy=Fail, reject the request\n - If failurePolicy=Ignore, the error is ignored and the webhook is skipped", + "items": { + "$ref": "#/definitions/v1.MatchCondition" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + }, "matchPolicy": { "description": "matchPolicy defines how the \"rules\" list is used to match incoming requests. Allowed values are \"Exact\" or \"Equivalent\".\n\n- Exact: match a request only if it exactly matches a specified rule. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, but \"rules\" only included `apiGroups:[\"apps\"], apiVersions:[\"v1\"], resources: [\"deployments\"]`, a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the webhook.\n\n- Equivalent: match a request if modifies a resource listed in rules, even via another API group or version. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, and \"rules\" only included `apiGroups:[\"apps\"], apiVersions:[\"v1\"], resources: [\"deployments\"]`, a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the webhook.\n\nDefaults to \"Equivalent\"", "type": "string" @@ -43,7 +146,8 @@ "items": { "$ref": "#/definitions/v1.RuleWithOperations" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "sideEffects": { "description": "SideEffects states whether this webhook has side effects. Acceptable values are: None, NoneOnDryRun (webhooks created via v1beta1 may also specify Some or Unknown). Webhooks with side effects MUST implement a reconciliation system, since a request may be rejected by a future step in the admission chain and the side effects therefore need to be undone. Requests with the dryRun attribute will be auto-rejected if they match a webhook with sideEffects == Unknown or Some.", @@ -84,6 +188,10 @@ "$ref": "#/definitions/v1.MutatingWebhook" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "name", "x-kubernetes-patch-strategy": "merge" } @@ -132,6 +240,95 @@ } ] }, + "v1.NamedRuleWithOperations": { + "description": "NamedRuleWithOperations is a tuple of Operations and Resources with ResourceNames.", + "properties": { + "apiGroups": { + "description": "APIGroups is the API groups the resources belong to. '*' is all groups. If '*' is present, the length of the slice must be one. Required.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "apiVersions": { + "description": "APIVersions is the API versions the resources belong to. '*' is all versions. If '*' is present, the length of the slice must be one. Required.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "operations": { + "description": "Operations is the operations the admission hook cares about - CREATE, UPDATE, DELETE, CONNECT or * for all of those operations and any future admission operations that are added. If '*' is present, the length of the slice must be one. Required.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "resourceNames": { + "description": "ResourceNames is an optional white list of names that the rule applies to. An empty set means that everything is allowed.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "resources": { + "description": "Resources is a list of resources this rule applies to.\n\nFor example: 'pods' means pods. 'pods/log' means the log subresource of pods. '*' means all resources, but not subresources. 'pods/*' means all subresources of pods. '*/scale' means all scale subresources. '*/*' means all resources and their subresources.\n\nIf wildcard is present, the validation rule will ensure resources do not overlap with each other.\n\nDepending on the enclosing object, subresources might not be allowed. Required.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "scope": { + "description": "scope specifies the scope of this rule. Valid values are \"Cluster\", \"Namespaced\", and \"*\" \"Cluster\" means that only cluster-scoped resources will match this rule. Namespace API objects are cluster-scoped. \"Namespaced\" means that only namespaced resources will match this rule. \"*\" means that there are no scope restrictions. Subresources match the scope of their parent resource. Default is \"*\".", + "type": "string" + } + }, + "type": "object", + "x-kubernetes-map-type": "atomic" + }, + "v1.ParamKind": { + "description": "ParamKind is a tuple of Group Kind and Version.", + "properties": { + "apiVersion": { + "description": "APIVersion is the API group version the resources belong to. In format of \"group/version\". Required.", + "type": "string" + }, + "kind": { + "description": "Kind is the API kind the resources belong to. Required.", + "type": "string" + } + }, + "type": "object", + "x-kubernetes-map-type": "atomic" + }, + "v1.ParamRef": { + "description": "ParamRef describes how to locate the params to be used as input to expressions of rules applied by a policy binding.", + "properties": { + "name": { + "description": "name is the name of the resource being referenced.\n\nOne of `name` or `selector` must be set, but `name` and `selector` are mutually exclusive properties. If one is set, the other must be unset.\n\nA single parameter used for all admission requests can be configured by setting the `name` field, leaving `selector` blank, and setting namespace if `paramKind` is namespace-scoped.", + "type": "string" + }, + "namespace": { + "description": "namespace is the namespace of the referenced resource. Allows limiting the search for params to a specific namespace. Applies to both `name` and `selector` fields.\n\nA per-namespace parameter may be used by specifying a namespace-scoped `paramKind` in the policy and leaving this field empty.\n\n- If `paramKind` is cluster-scoped, this field MUST be unset. Setting this field results in a configuration error.\n\n- If `paramKind` is namespace-scoped, the namespace of the object being evaluated for admission will be used when this field is left unset. Take care that if this is left empty the binding must not match any cluster-scoped resources, which will result in an error.", + "type": "string" + }, + "parameterNotFoundAction": { + "description": "`parameterNotFoundAction` controls the behavior of the binding when the resource exists, and name or selector is valid, but there are no parameters matched by the binding. If the value is set to `Allow`, then no matched parameters will be treated as successful validation by the binding. If set to `Deny`, then no matched parameters will be subject to the `failurePolicy` of the policy.\n\nAllowed values are `Allow` or `Deny`\n\nRequired", + "type": "string" + }, + "selector": { + "$ref": "#/definitions/v1.LabelSelector", + "description": "selector can be used to match multiple param objects based on their labels. Supply selector: {} to match all resources of the ParamKind.\n\nIf multiple params are found, they are all evaluated with the policy expressions and the results are ANDed together.\n\nOne of `name` or `selector` must be set, but `name` and `selector` are mutually exclusive properties. If one is set, the other must be unset." + } + }, + "type": "object", + "x-kubernetes-map-type": "atomic" + }, "v1.RuleWithOperations": { "description": "RuleWithOperations is a tuple of Operations and Resources. It is recommended to make sure that all the tuple expansions are valid.", "properties": { @@ -140,28 +337,32 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "apiVersions": { "description": "APIVersions is the API versions the resources belong to. '*' is all versions. If '*' is present, the length of the slice must be one. Required.", "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "operations": { "description": "Operations is the operations the admission hook cares about - CREATE, UPDATE, DELETE, CONNECT or * for all of those operations and any future admission operations that are added. If '*' is present, the length of the slice must be one. Required.", "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "resources": { "description": "Resources is a list of resources this rule applies to.\n\nFor example: 'pods' means pods. 'pods/log' means the log subresource of pods. '*' means all resources, but not subresources. 'pods/*' means all subresources of pods. '*/scale' means all scale subresources. '*/*' means all resources and their subresources.\n\nIf wildcard is present, the validation rule will ensure resources do not overlap with each other.\n\nDepending on the enclosing object, subresources might not be allowed. Required.", "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "scope": { "description": "scope specifies the scope of this rule. Valid values are \"Cluster\", \"Namespaced\", and \"*\" \"Cluster\" means that only cluster-scoped resources will match this rule. Namespace API objects are cluster-scoped. \"Namespaced\" means that only namespaced resources will match this rule. \"*\" means that there are no scope restrictions. Subresources match the scope of their parent resource. Default is \"*\".", @@ -197,6 +398,264 @@ ], "type": "object" }, + "v1.TypeChecking": { + "description": "TypeChecking contains results of type checking the expressions in the ValidatingAdmissionPolicy", + "properties": { + "expressionWarnings": { + "description": "The type checking warnings for each expression.", + "items": { + "$ref": "#/definitions/v1.ExpressionWarning" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + } + }, + "type": "object" + }, + "v1.ValidatingAdmissionPolicy": { + "description": "ValidatingAdmissionPolicy describes the definition of an admission validation policy that accepts or rejects an object without changing it.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/v1.ObjectMeta", + "description": "Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata." + }, + "spec": { + "$ref": "#/definitions/v1.ValidatingAdmissionPolicySpec", + "description": "Specification of the desired behavior of the ValidatingAdmissionPolicy." + }, + "status": { + "$ref": "#/definitions/v1.ValidatingAdmissionPolicyStatus", + "description": "The status of the ValidatingAdmissionPolicy, including warnings that are useful to determine if the policy behaves in the expected way. Populated by the system. Read-only." + } + }, + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "admissionregistration.k8s.io", + "kind": "ValidatingAdmissionPolicy", + "version": "v1" + } + ] + }, + "v1.ValidatingAdmissionPolicyBinding": { + "description": "ValidatingAdmissionPolicyBinding binds the ValidatingAdmissionPolicy with paramerized resources. ValidatingAdmissionPolicyBinding and parameter CRDs together define how cluster administrators configure policies for clusters.\n\nFor a given admission request, each binding will cause its policy to be evaluated N times, where N is 1 for policies/bindings that don't use params, otherwise N is the number of parameters selected by the binding.\n\nThe CEL expressions of a policy must have a computed CEL cost below the maximum CEL budget. Each evaluation of the policy is given an independent CEL cost budget. Adding/removing policies, bindings, or params can not affect whether a given (policy, binding, param) combination is within its own CEL budget.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/v1.ObjectMeta", + "description": "Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata." + }, + "spec": { + "$ref": "#/definitions/v1.ValidatingAdmissionPolicyBindingSpec", + "description": "Specification of the desired behavior of the ValidatingAdmissionPolicyBinding." + } + }, + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "admissionregistration.k8s.io", + "kind": "ValidatingAdmissionPolicyBinding", + "version": "v1" + } + ] + }, + "v1.ValidatingAdmissionPolicyBindingList": { + "description": "ValidatingAdmissionPolicyBindingList is a list of ValidatingAdmissionPolicyBinding.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of PolicyBinding.", + "items": { + "$ref": "#/definitions/v1.ValidatingAdmissionPolicyBinding" + }, + "type": "array" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/v1.ListMeta", + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds" + } + }, + "required": [ + "items" + ], + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "admissionregistration.k8s.io", + "kind": "ValidatingAdmissionPolicyBindingList", + "version": "v1" + } + ] + }, + "v1.ValidatingAdmissionPolicyBindingSpec": { + "description": "ValidatingAdmissionPolicyBindingSpec is the specification of the ValidatingAdmissionPolicyBinding.", + "properties": { + "matchResources": { + "$ref": "#/definitions/v1.MatchResources", + "description": "MatchResources declares what resources match this binding and will be validated by it. Note that this is intersected with the policy's matchConstraints, so only requests that are matched by the policy can be selected by this. If this is unset, all resources matched by the policy are validated by this binding When resourceRules is unset, it does not constrain resource matching. If a resource is matched by the other fields of this object, it will be validated. Note that this is differs from ValidatingAdmissionPolicy matchConstraints, where resourceRules are required." + }, + "paramRef": { + "$ref": "#/definitions/v1.ParamRef", + "description": "paramRef specifies the parameter resource used to configure the admission control policy. It should point to a resource of the type specified in ParamKind of the bound ValidatingAdmissionPolicy. If the policy specifies a ParamKind and the resource referred to by ParamRef does not exist, this binding is considered mis-configured and the FailurePolicy of the ValidatingAdmissionPolicy applied. If the policy does not specify a ParamKind then this field is ignored, and the rules are evaluated without a param." + }, + "policyName": { + "description": "PolicyName references a ValidatingAdmissionPolicy name which the ValidatingAdmissionPolicyBinding binds to. If the referenced resource does not exist, this binding is considered invalid and will be ignored Required.", + "type": "string" + }, + "validationActions": { + "description": "validationActions declares how Validations of the referenced ValidatingAdmissionPolicy are enforced. If a validation evaluates to false it is always enforced according to these actions.\n\nFailures defined by the ValidatingAdmissionPolicy's FailurePolicy are enforced according to these actions only if the FailurePolicy is set to Fail, otherwise the failures are ignored. This includes compilation errors, runtime errors and misconfigurations of the policy.\n\nvalidationActions is declared as a set of action values. Order does not matter. validationActions may not contain duplicates of the same action.\n\nThe supported actions values are:\n\n\"Deny\" specifies that a validation failure results in a denied request.\n\n\"Warn\" specifies that a validation failure is reported to the request client in HTTP Warning headers, with a warning code of 299. Warnings can be sent both for allowed or denied admission responses.\n\n\"Audit\" specifies that a validation failure is included in the published audit event for the request. The audit event will contain a `validation.policy.admission.k8s.io/validation_failure` audit annotation with a value containing the details of the validation failures, formatted as a JSON list of objects, each with the following fields: - message: The validation failure message string - policy: The resource name of the ValidatingAdmissionPolicy - binding: The resource name of the ValidatingAdmissionPolicyBinding - expressionIndex: The index of the failed validations in the ValidatingAdmissionPolicy - validationActions: The enforcement actions enacted for the validation failure Example audit annotation: `\"validation.policy.admission.k8s.io/validation_failure\": \"[{\\\"message\\\": \\\"Invalid value\\\", {\\\"policy\\\": \\\"policy.example.com\\\", {\\\"binding\\\": \\\"policybinding.example.com\\\", {\\\"expressionIndex\\\": \\\"1\\\", {\\\"validationActions\\\": [\\\"Audit\\\"]}]\"`\n\nClients should expect to handle additional values by ignoring any values not recognized.\n\n\"Deny\" and \"Warn\" may not be used together since this combination needlessly duplicates the validation failure both in the API response body and the HTTP warning headers.\n\nRequired.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "set" + } + }, + "type": "object" + }, + "v1.ValidatingAdmissionPolicyList": { + "description": "ValidatingAdmissionPolicyList is a list of ValidatingAdmissionPolicy.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of ValidatingAdmissionPolicy.", + "items": { + "$ref": "#/definitions/v1.ValidatingAdmissionPolicy" + }, + "type": "array" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/v1.ListMeta", + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds" + } + }, + "required": [ + "items" + ], + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "admissionregistration.k8s.io", + "kind": "ValidatingAdmissionPolicyList", + "version": "v1" + } + ] + }, + "v1.ValidatingAdmissionPolicySpec": { + "description": "ValidatingAdmissionPolicySpec is the specification of the desired behavior of the AdmissionPolicy.", + "properties": { + "auditAnnotations": { + "description": "auditAnnotations contains CEL expressions which are used to produce audit annotations for the audit event of the API request. validations and auditAnnotations may not both be empty; a least one of validations or auditAnnotations is required.", + "items": { + "$ref": "#/definitions/v1.AuditAnnotation" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "failurePolicy": { + "description": "failurePolicy defines how to handle failures for the admission policy. Failures can occur from CEL expression parse errors, type check errors, runtime errors and invalid or mis-configured policy definitions or bindings.\n\nA policy is invalid if spec.paramKind refers to a non-existent Kind. A binding is invalid if spec.paramRef.name refers to a non-existent resource.\n\nfailurePolicy does not define how validations that evaluate to false are handled.\n\nWhen failurePolicy is set to Fail, ValidatingAdmissionPolicyBinding validationActions define how failures are enforced.\n\nAllowed values are Ignore or Fail. Defaults to Fail.", + "type": "string" + }, + "matchConditions": { + "description": "MatchConditions is a list of conditions that must be met for a request to be validated. Match conditions filter requests that have already been matched by the rules, namespaceSelector, and objectSelector. An empty list of matchConditions matches all requests. There are a maximum of 64 match conditions allowed.\n\nIf a parameter object is provided, it can be accessed via the `params` handle in the same manner as validation expressions.\n\nThe exact matching logic is (in order):\n 1. If ANY matchCondition evaluates to FALSE, the policy is skipped.\n 2. If ALL matchConditions evaluate to TRUE, the policy is evaluated.\n 3. If any matchCondition evaluates to an error (but none are FALSE):\n - If failurePolicy=Fail, reject the request\n - If failurePolicy=Ignore, the policy is skipped", + "items": { + "$ref": "#/definitions/v1.MatchCondition" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + }, + "matchConstraints": { + "$ref": "#/definitions/v1.MatchResources", + "description": "MatchConstraints specifies what resources this policy is designed to validate. The AdmissionPolicy cares about a request if it matches _all_ Constraints. However, in order to prevent clusters from being put into an unstable state that cannot be recovered from via the API ValidatingAdmissionPolicy cannot match ValidatingAdmissionPolicy and ValidatingAdmissionPolicyBinding. Required." + }, + "paramKind": { + "$ref": "#/definitions/v1.ParamKind", + "description": "ParamKind specifies the kind of resources used to parameterize this policy. If absent, there are no parameters for this policy and the param CEL variable will not be provided to validation expressions. If ParamKind refers to a non-existent kind, this policy definition is mis-configured and the FailurePolicy is applied. If paramKind is specified but paramRef is unset in ValidatingAdmissionPolicyBinding, the params variable will be null." + }, + "validations": { + "description": "Validations contain CEL expressions which is used to apply the validation. Validations and AuditAnnotations may not both be empty; a minimum of one Validations or AuditAnnotations is required.", + "items": { + "$ref": "#/definitions/v1.Validation" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "variables": { + "description": "Variables contain definitions of variables that can be used in composition of other expressions. Each variable is defined as a named CEL expression. The variables defined here will be available under `variables` in other expressions of the policy except MatchConditions because MatchConditions are evaluated before the rest of the policy.\n\nThe expression of a variable can refer to other variables defined earlier in the list but not those after. Thus, Variables must be sorted by the order of first appearance and acyclic.", + "items": { + "$ref": "#/definitions/v1.Variable" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + } + }, + "type": "object" + }, + "v1.ValidatingAdmissionPolicyStatus": { + "description": "ValidatingAdmissionPolicyStatus represents the status of an admission validation policy.", + "properties": { + "conditions": { + "description": "The conditions represent the latest available observations of a policy's current state.", + "items": { + "$ref": "#/definitions/v1.Condition" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map" + }, + "observedGeneration": { + "description": "The generation observed by the controller.", + "format": "int64", + "type": "integer" + }, + "typeChecking": { + "$ref": "#/definitions/v1.TypeChecking", + "description": "The results of type checking for each expression. Presence of this field indicates the completion of the type checking." + } + }, + "type": "object" + }, "v1.ValidatingWebhook": { "description": "ValidatingWebhook describes an admission webhook and the resources and operations it applies to.", "properties": { @@ -205,7 +664,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "clientConfig": { "$ref": "#/definitions/admissionregistration.v1.WebhookClientConfig", @@ -215,6 +675,19 @@ "description": "FailurePolicy defines how unrecognized errors from the admission endpoint are handled - allowed values are Ignore or Fail. Defaults to Fail.", "type": "string" }, + "matchConditions": { + "description": "MatchConditions is a list of conditions that must be met for a request to be sent to this webhook. Match conditions filter requests that have already been matched by the rules, namespaceSelector, and objectSelector. An empty list of matchConditions matches all requests. There are a maximum of 64 match conditions allowed.\n\nThe exact matching logic is (in order):\n 1. If ANY matchCondition evaluates to FALSE, the webhook is skipped.\n 2. If ALL matchConditions evaluate to TRUE, the webhook is called.\n 3. If any matchCondition evaluates to an error (but none are FALSE):\n - If failurePolicy=Fail, reject the request\n - If failurePolicy=Ignore, the error is ignored and the webhook is skipped", + "items": { + "$ref": "#/definitions/v1.MatchCondition" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + }, "matchPolicy": { "description": "matchPolicy defines how the \"rules\" list is used to match incoming requests. Allowed values are \"Exact\" or \"Equivalent\".\n\n- Exact: match a request only if it exactly matches a specified rule. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, but \"rules\" only included `apiGroups:[\"apps\"], apiVersions:[\"v1\"], resources: [\"deployments\"]`, a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the webhook.\n\n- Equivalent: match a request if modifies a resource listed in rules, even via another API group or version. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, and \"rules\" only included `apiGroups:[\"apps\"], apiVersions:[\"v1\"], resources: [\"deployments\"]`, a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the webhook.\n\nDefaults to \"Equivalent\"", "type": "string" @@ -236,7 +709,8 @@ "items": { "$ref": "#/definitions/v1.RuleWithOperations" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "sideEffects": { "description": "SideEffects states whether this webhook has side effects. Acceptable values are: None, NoneOnDryRun (webhooks created via v1beta1 may also specify Some or Unknown). Webhooks with side effects MUST implement a reconciliation system, since a request may be rejected by a future step in the admission chain and the side effects therefore need to be undone. Requests with the dryRun attribute will be auto-rejected if they match a webhook with sideEffects == Unknown or Some.", @@ -277,6 +751,10 @@ "$ref": "#/definitions/v1.ValidatingWebhook" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "name", "x-kubernetes-patch-strategy": "merge" } @@ -325,6 +803,50 @@ } ] }, + "v1.Validation": { + "description": "Validation specifies the CEL expression which is used to apply the validation.", + "properties": { + "expression": { + "description": "Expression represents the expression which will be evaluated by CEL. ref: https://github.com/google/cel-spec CEL expressions have access to the contents of the API request/response, organized into CEL variables as well as some other useful variables:\n\n- 'object' - The object from the incoming request. The value is null for DELETE requests. - 'oldObject' - The existing object. The value is null for CREATE requests. - 'request' - Attributes of the API request([ref](/pkg/apis/admission/types.go#AdmissionRequest)). - 'params' - Parameter resource referred to by the policy binding being evaluated. Only populated if the policy has a ParamKind. - 'namespaceObject' - The namespace object that the incoming object belongs to. The value is null for cluster-scoped resources. - 'variables' - Map of composited variables, from its name to its lazily evaluated value.\n For example, a variable named 'foo' can be accessed as 'variables.foo'.\n- 'authorizer' - A CEL Authorizer. May be used to perform authorization checks for the principal (user or service account) of the request.\n See https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz\n- 'authorizer.requestResource' - A CEL ResourceCheck constructed from the 'authorizer' and configured with the\n request resource.\n\nThe `apiVersion`, `kind`, `metadata.name` and `metadata.generateName` are always accessible from the root of the object. No other metadata properties are accessible.\n\nOnly property names of the form `[a-zA-Z_.-/][a-zA-Z0-9_.-/]*` are accessible. Accessible property names are escaped according to the following rules when accessed in the expression: - '__' escapes to '__underscores__' - '.' escapes to '__dot__' - '-' escapes to '__dash__' - '/' escapes to '__slash__' - Property names that exactly match a CEL RESERVED keyword escape to '__{keyword}__'. The keywords are:\n\t \"true\", \"false\", \"null\", \"in\", \"as\", \"break\", \"const\", \"continue\", \"else\", \"for\", \"function\", \"if\",\n\t \"import\", \"let\", \"loop\", \"package\", \"namespace\", \"return\".\nExamples:\n - Expression accessing a property named \"namespace\": {\"Expression\": \"object.__namespace__ > 0\"}\n - Expression accessing a property named \"x-prop\": {\"Expression\": \"object.x__dash__prop > 0\"}\n - Expression accessing a property named \"redact__d\": {\"Expression\": \"object.redact__underscores__d > 0\"}\n\nEquality on arrays with list type of 'set' or 'map' ignores element order, i.e. [1, 2] == [2, 1]. Concatenation on arrays with x-kubernetes-list-type use the semantics of the list type:\n - 'set': `X + Y` performs a union where the array positions of all elements in `X` are preserved and\n non-intersecting elements in `Y` are appended, retaining their partial order.\n - 'map': `X + Y` performs a merge where the array positions of all keys in `X` are preserved but the values\n are overwritten by values in `Y` when the key sets of `X` and `Y` intersect. Elements in `Y` with\n non-intersecting keys are appended, retaining their partial order.\nRequired.", + "type": "string" + }, + "message": { + "description": "Message represents the message displayed when validation fails. The message is required if the Expression contains line breaks. The message must not contain line breaks. If unset, the message is \"failed rule: {Rule}\". e.g. \"must be a URL with the host matching spec.host\" If the Expression contains line breaks. Message is required. The message must not contain line breaks. If unset, the message is \"failed Expression: {Expression}\".", + "type": "string" + }, + "messageExpression": { + "description": "messageExpression declares a CEL expression that evaluates to the validation failure message that is returned when this rule fails. Since messageExpression is used as a failure message, it must evaluate to a string. If both message and messageExpression are present on a validation, then messageExpression will be used if validation fails. If messageExpression results in a runtime error, the runtime error is logged, and the validation failure message is produced as if the messageExpression field were unset. If messageExpression evaluates to an empty string, a string with only spaces, or a string that contains line breaks, then the validation failure message will also be produced as if the messageExpression field were unset, and the fact that messageExpression produced an empty string/string with only spaces/string with line breaks will be logged. messageExpression has access to all the same variables as the `expression` except for 'authorizer' and 'authorizer.requestResource'. Example: \"object.x must be less than max (\"+string(params.max)+\")\"", + "type": "string" + }, + "reason": { + "description": "Reason represents a machine-readable description of why this validation failed. If this is the first validation in the list to fail, this reason, as well as the corresponding HTTP response code, are used in the HTTP response to the client. The currently supported reasons are: \"Unauthorized\", \"Forbidden\", \"Invalid\", \"RequestEntityTooLarge\". If not set, StatusReasonInvalid is used in the response to the client.", + "type": "string" + } + }, + "required": [ + "expression" + ], + "type": "object" + }, + "v1.Variable": { + "description": "Variable is the definition of a variable that is used for composition. A variable is defined as a named expression.", + "properties": { + "expression": { + "description": "Expression is the expression that will be evaluated as the value of the variable. The CEL expression has access to the same identifiers as the CEL expressions in Validation.", + "type": "string" + }, + "name": { + "description": "Name is the name of the variable. The name must be a valid CEL identifier and unique among all variables. The variable can be accessed in other expressions through `variables` For example, if name is \"foo\", the variable will be available as `variables.foo`", + "type": "string" + } + }, + "required": [ + "name", + "expression" + ], + "type": "object", + "x-kubernetes-map-type": "atomic" + }, "admissionregistration.v1.WebhookClientConfig": { "description": "WebhookClientConfig contains the information to make a TLS connection with the webhook", "properties": { @@ -344,30 +866,80 @@ }, "type": "object" }, - "v1alpha1.ServerStorageVersion": { - "description": "An API server instance reports the version it can decode and the version it encodes objects to when persisting objects in the backend.", + "v1alpha1.ApplyConfiguration": { + "description": "ApplyConfiguration defines the desired configuration values of an object.", "properties": { - "apiServerID": { - "description": "The ID of the reporting API server.", + "expression": { + "description": "expression will be evaluated by CEL to create an apply configuration. ref: https://github.com/google/cel-spec\n\nApply configurations are declared in CEL using object initialization. For example, this CEL expression returns an apply configuration to set a single field:\n\n\tObject{\n\t spec: Object.spec{\n\t serviceAccountName: \"example\"\n\t }\n\t}\n\nApply configurations may not modify atomic structs, maps or arrays due to the risk of accidental deletion of values not included in the apply configuration.\n\nCEL expressions have access to the object types needed to create apply configurations:\n\n- 'Object' - CEL type of the resource object. - 'Object.' - CEL type of object field (such as 'Object.spec') - 'Object.....` - CEL type of nested field (such as 'Object.spec.containers')\n\nCEL expressions have access to the contents of the API request, organized into CEL variables as well as some other useful variables:\n\n- 'object' - The object from the incoming request. The value is null for DELETE requests. - 'oldObject' - The existing object. The value is null for CREATE requests. - 'request' - Attributes of the API request([ref](/pkg/apis/admission/types.go#AdmissionRequest)). - 'params' - Parameter resource referred to by the policy binding being evaluated. Only populated if the policy has a ParamKind. - 'namespaceObject' - The namespace object that the incoming object belongs to. The value is null for cluster-scoped resources. - 'variables' - Map of composited variables, from its name to its lazily evaluated value.\n For example, a variable named 'foo' can be accessed as 'variables.foo'.\n- 'authorizer' - A CEL Authorizer. May be used to perform authorization checks for the principal (user or service account) of the request.\n See https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz\n- 'authorizer.requestResource' - A CEL ResourceCheck constructed from the 'authorizer' and configured with the\n request resource.\n\nThe `apiVersion`, `kind`, `metadata.name` and `metadata.generateName` are always accessible from the root of the object. No other metadata properties are accessible.\n\nOnly property names of the form `[a-zA-Z_.-/][a-zA-Z0-9_.-/]*` are accessible. Required.", + "type": "string" + } + }, + "type": "object" + }, + "v1alpha1.JSONPatch": { + "description": "JSONPatch defines a JSON Patch.", + "properties": { + "expression": { + "description": "expression will be evaluated by CEL to create a [JSON patch](https://jsonpatch.com/). ref: https://github.com/google/cel-spec\n\nexpression must return an array of JSONPatch values.\n\nFor example, this CEL expression returns a JSON patch to conditionally modify a value:\n\n\t [\n\t JSONPatch{op: \"test\", path: \"/spec/example\", value: \"Red\"},\n\t JSONPatch{op: \"replace\", path: \"/spec/example\", value: \"Green\"}\n\t ]\n\nTo define an object for the patch value, use Object types. For example:\n\n\t [\n\t JSONPatch{\n\t op: \"add\",\n\t path: \"/spec/selector\",\n\t value: Object.spec.selector{matchLabels: {\"environment\": \"test\"}}\n\t }\n\t ]\n\nTo use strings containing '/' and '~' as JSONPatch path keys, use \"jsonpatch.escapeKey\". For example:\n\n\t [\n\t JSONPatch{\n\t op: \"add\",\n\t path: \"/metadata/labels/\" + jsonpatch.escapeKey(\"example.com/environment\"),\n\t value: \"test\"\n\t },\n\t ]\n\nCEL expressions have access to the types needed to create JSON patches and objects:\n\n- 'JSONPatch' - CEL type of JSON Patch operations. JSONPatch has the fields 'op', 'from', 'path' and 'value'.\n See [JSON patch](https://jsonpatch.com/) for more details. The 'value' field may be set to any of: string,\n integer, array, map or object. If set, the 'path' and 'from' fields must be set to a\n [JSON pointer](https://datatracker.ietf.org/doc/html/rfc6901/) string, where the 'jsonpatch.escapeKey()' CEL\n function may be used to escape path keys containing '/' and '~'.\n- 'Object' - CEL type of the resource object. - 'Object.' - CEL type of object field (such as 'Object.spec') - 'Object.....` - CEL type of nested field (such as 'Object.spec.containers')\n\nCEL expressions have access to the contents of the API request, organized into CEL variables as well as some other useful variables:\n\n- 'object' - The object from the incoming request. The value is null for DELETE requests. - 'oldObject' - The existing object. The value is null for CREATE requests. - 'request' - Attributes of the API request([ref](/pkg/apis/admission/types.go#AdmissionRequest)). - 'params' - Parameter resource referred to by the policy binding being evaluated. Only populated if the policy has a ParamKind. - 'namespaceObject' - The namespace object that the incoming object belongs to. The value is null for cluster-scoped resources. - 'variables' - Map of composited variables, from its name to its lazily evaluated value.\n For example, a variable named 'foo' can be accessed as 'variables.foo'.\n- 'authorizer' - A CEL Authorizer. May be used to perform authorization checks for the principal (user or service account) of the request.\n See https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz\n- 'authorizer.requestResource' - A CEL ResourceCheck constructed from the 'authorizer' and configured with the\n request resource.\n\nCEL expressions have access to [Kubernetes CEL function libraries](https://kubernetes.io/docs/reference/using-api/cel/#cel-options-language-features-and-libraries) as well as:\n\n- 'jsonpatch.escapeKey' - Performs JSONPatch key escaping. '~' and '/' are escaped as '~0' and `~1' respectively).\n\nOnly property names of the form `[a-zA-Z_.-/][a-zA-Z0-9_.-/]*` are accessible. Required.", + "type": "string" + } + }, + "type": "object" + }, + "v1alpha1.MatchCondition": { + "properties": { + "expression": { + "description": "Expression represents the expression which will be evaluated by CEL. Must evaluate to bool. CEL expressions have access to the contents of the AdmissionRequest and Authorizer, organized into CEL variables:\n\n'object' - The object from the incoming request. The value is null for DELETE requests. 'oldObject' - The existing object. The value is null for CREATE requests. 'request' - Attributes of the admission request(/pkg/apis/admission/types.go#AdmissionRequest). 'authorizer' - A CEL Authorizer. May be used to perform authorization checks for the principal (user or service account) of the request.\n See https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz\n'authorizer.requestResource' - A CEL ResourceCheck constructed from the 'authorizer' and configured with the\n request resource.\nDocumentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/\n\nRequired.", "type": "string" }, - "decodableVersions": { - "description": "The API server can decode objects encoded in these versions. The encodingVersion must be included in the decodableVersions.", + "name": { + "description": "Name is an identifier for this match condition, used for strategic merging of MatchConditions, as well as providing an identifier for logging purposes. A good name should be descriptive of the associated expression. Name must be a qualified name consisting of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName', or 'my.name', or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]') with an optional DNS subdomain prefix and '/' (e.g. 'example.com/MyName')\n\nRequired.", + "type": "string" + } + }, + "required": [ + "name", + "expression" + ], + "type": "object" + }, + "v1alpha1.MatchResources": { + "description": "MatchResources decides whether to run the admission control policy on an object based on whether it meets the match criteria. The exclude rules take precedence over include rules (if a resource matches both, it is excluded)", + "properties": { + "excludeResourceRules": { + "description": "ExcludeResourceRules describes what operations on what resources/subresources the policy should not care about. The exclude rules take precedence over include rules (if a resource matches both, it is excluded)", "items": { - "type": "string" + "$ref": "#/definitions/v1alpha1.NamedRuleWithOperations" }, "type": "array", - "x-kubernetes-list-type": "set" + "x-kubernetes-list-type": "atomic" }, - "encodingVersion": { - "description": "The API server encodes the object to this version when persisting it in the backend (e.g., etcd).", + "matchPolicy": { + "description": "matchPolicy defines how the \"MatchResources\" list is used to match incoming requests. Allowed values are \"Exact\" or \"Equivalent\".\n\n- Exact: match a request only if it exactly matches a specified rule. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, but \"rules\" only included `apiGroups:[\"apps\"], apiVersions:[\"v1\"], resources: [\"deployments\"]`, the admission policy does not consider requests to apps/v1beta1 or extensions/v1beta1 API groups.\n\n- Equivalent: match a request if modifies a resource listed in rules, even via another API group or version. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, and \"rules\" only included `apiGroups:[\"apps\"], apiVersions:[\"v1\"], resources: [\"deployments\"]`, the admission policy **does** consider requests made to apps/v1beta1 or extensions/v1beta1 API groups. The API server translates the request to a matched resource API if necessary.\n\nDefaults to \"Equivalent\"", "type": "string" + }, + "namespaceSelector": { + "$ref": "#/definitions/v1.LabelSelector", + "description": "NamespaceSelector decides whether to run the admission control policy on an object based on whether the namespace for that object matches the selector. If the object itself is a namespace, the matching is performed on object.metadata.labels. If the object is another cluster scoped resource, it never skips the policy.\n\nFor example, to run the webhook on any objects whose namespace is not associated with \"runlevel\" of \"0\" or \"1\"; you will set the selector as follows: \"namespaceSelector\": {\n \"matchExpressions\": [\n {\n \"key\": \"runlevel\",\n \"operator\": \"NotIn\",\n \"values\": [\n \"0\",\n \"1\"\n ]\n }\n ]\n}\n\nIf instead you want to only run the policy on any objects whose namespace is associated with the \"environment\" of \"prod\" or \"staging\"; you will set the selector as follows: \"namespaceSelector\": {\n \"matchExpressions\": [\n {\n \"key\": \"environment\",\n \"operator\": \"In\",\n \"values\": [\n \"prod\",\n \"staging\"\n ]\n }\n ]\n}\n\nSee https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ for more examples of label selectors.\n\nDefault to the empty LabelSelector, which matches everything." + }, + "objectSelector": { + "$ref": "#/definitions/v1.LabelSelector", + "description": "ObjectSelector decides whether to run the policy based on if the object has matching labels. objectSelector is evaluated against both the oldObject and newObject that would be sent to the policy's expression (CEL), and is considered to match if either object matches the selector. A null object (oldObject in the case of create, or newObject in the case of delete) or an object that cannot have labels (like a DeploymentRollback or a PodProxyOptions object) is not considered to match. Use the object selector only if the webhook is opt-in, because end users may skip the admission webhook by setting the labels. Default to the empty LabelSelector, which matches everything." + }, + "resourceRules": { + "description": "ResourceRules describes what operations on what resources/subresources the admission policy matches. The policy cares about an operation if it matches _any_ Rule.", + "items": { + "$ref": "#/definitions/v1alpha1.NamedRuleWithOperations" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" } }, - "type": "object" + "type": "object", + "x-kubernetes-map-type": "atomic" }, - "v1alpha1.StorageVersion": { - "description": "Storage version of a specific resource.", + "v1alpha1.MutatingAdmissionPolicy": { + "description": "MutatingAdmissionPolicy describes the definition of an admission mutation policy that mutates the object coming into admission chain.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", @@ -379,78 +951,62 @@ }, "metadata": { "$ref": "#/definitions/v1.ObjectMeta", - "description": "The name is .." + "description": "Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata." }, "spec": { - "description": "Spec is an empty spec. It is here to comply with Kubernetes API style.", - "type": "object" - }, - "status": { - "$ref": "#/definitions/v1alpha1.StorageVersionStatus", - "description": "API server instances report the version they can decode and the version they encode objects to when persisting objects in the backend." + "$ref": "#/definitions/v1alpha1.MutatingAdmissionPolicySpec", + "description": "Specification of the desired behavior of the MutatingAdmissionPolicy." } }, - "required": [ - "spec", - "status" - ], "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "internal.apiserver.k8s.io", - "kind": "StorageVersion", + "group": "admissionregistration.k8s.io", + "kind": "MutatingAdmissionPolicy", "version": "v1alpha1" } ] }, - "v1alpha1.StorageVersionCondition": { - "description": "Describes the state of the storageVersion at a certain point.", + "v1alpha1.MutatingAdmissionPolicyBinding": { + "description": "MutatingAdmissionPolicyBinding binds the MutatingAdmissionPolicy with parametrized resources. MutatingAdmissionPolicyBinding and the optional parameter resource together define how cluster administrators configure policies for clusters.\n\nFor a given admission request, each binding will cause its policy to be evaluated N times, where N is 1 for policies/bindings that don't use params, otherwise N is the number of parameters selected by the binding. Each evaluation is constrained by a [runtime cost budget](https://kubernetes.io/docs/reference/using-api/cel/#runtime-cost-budget).\n\nAdding/removing policies, bindings, or params can not affect whether a given (policy, binding, param) combination is within its own CEL budget.", "properties": { - "lastTransitionTime": { - "description": "Last time the condition transitioned from one status to another.", - "format": "date-time", - "type": "string" - }, - "message": { - "description": "A human readable message indicating details about the transition.", + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, - "observedGeneration": { - "description": "If set, this represents the .metadata.generation that the condition was set based upon.", - "format": "int64", - "type": "integer" - }, - "reason": { - "description": "The reason for the condition's last transition.", + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", "type": "string" }, - "status": { - "description": "Status of the condition, one of True, False, Unknown.", - "type": "string" + "metadata": { + "$ref": "#/definitions/v1.ObjectMeta", + "description": "Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata." }, - "type": { - "description": "Type of the condition.", - "type": "string" + "spec": { + "$ref": "#/definitions/v1alpha1.MutatingAdmissionPolicyBindingSpec", + "description": "Specification of the desired behavior of the MutatingAdmissionPolicyBinding." } }, - "required": [ - "type", - "status", - "reason" - ], - "type": "object" - }, - "v1alpha1.StorageVersionList": { - "description": "A list of StorageVersions.", + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "admissionregistration.k8s.io", + "kind": "MutatingAdmissionPolicyBinding", + "version": "v1alpha1" + } + ] + }, + "v1alpha1.MutatingAdmissionPolicyBindingList": { + "description": "MutatingAdmissionPolicyBindingList is a list of MutatingAdmissionPolicyBinding.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, "items": { - "description": "Items holds a list of StorageVersion", + "description": "List of PolicyBinding.", "items": { - "$ref": "#/definitions/v1alpha1.StorageVersion" + "$ref": "#/definitions/v1alpha1.MutatingAdmissionPolicyBinding" }, "type": "array" }, @@ -460,7 +1016,7 @@ }, "metadata": { "$ref": "#/definitions/v1.ListMeta", - "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds" } }, "required": [ @@ -469,329 +1025,348 @@ "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "internal.apiserver.k8s.io", - "kind": "StorageVersionList", + "group": "admissionregistration.k8s.io", + "kind": "MutatingAdmissionPolicyBindingList", "version": "v1alpha1" } ] }, - "v1alpha1.StorageVersionStatus": { - "description": "API server instances report the versions they can decode and the version they encode objects to when persisting objects in the backend.", + "v1alpha1.MutatingAdmissionPolicyBindingSpec": { + "description": "MutatingAdmissionPolicyBindingSpec is the specification of the MutatingAdmissionPolicyBinding.", "properties": { - "commonEncodingVersion": { - "description": "If all API server instances agree on the same encoding storage version, then this field is set to that version. Otherwise this field is left empty. API servers should finish updating its storageVersionStatus entry before serving write operations, so that this field will be in sync with the reality.", - "type": "string" + "matchResources": { + "$ref": "#/definitions/v1alpha1.MatchResources", + "description": "matchResources limits what resources match this binding and may be mutated by it. Note that if matchResources matches a resource, the resource must also match a policy's matchConstraints and matchConditions before the resource may be mutated. When matchResources is unset, it does not constrain resource matching, and only the policy's matchConstraints and matchConditions must match for the resource to be mutated. Additionally, matchResources.resourceRules are optional and do not constraint matching when unset. Note that this is differs from MutatingAdmissionPolicy matchConstraints, where resourceRules are required. The CREATE, UPDATE and CONNECT operations are allowed. The DELETE operation may not be matched. '*' matches CREATE, UPDATE and CONNECT." }, - "conditions": { - "description": "The latest available observations of the storageVersion's state.", - "items": { - "$ref": "#/definitions/v1alpha1.StorageVersionCondition" - }, - "type": "array", - "x-kubernetes-list-map-keys": [ - "type" - ], - "x-kubernetes-list-type": "map" + "paramRef": { + "$ref": "#/definitions/v1alpha1.ParamRef", + "description": "paramRef specifies the parameter resource used to configure the admission control policy. It should point to a resource of the type specified in spec.ParamKind of the bound MutatingAdmissionPolicy. If the policy specifies a ParamKind and the resource referred to by ParamRef does not exist, this binding is considered mis-configured and the FailurePolicy of the MutatingAdmissionPolicy applied. If the policy does not specify a ParamKind then this field is ignored, and the rules are evaluated without a param." }, - "storageVersions": { - "description": "The reported versions per API server instance.", - "items": { - "$ref": "#/definitions/v1alpha1.ServerStorageVersion" - }, - "type": "array", - "x-kubernetes-list-map-keys": [ - "apiServerID" - ], - "x-kubernetes-list-type": "map" + "policyName": { + "description": "policyName references a MutatingAdmissionPolicy name which the MutatingAdmissionPolicyBinding binds to. If the referenced resource does not exist, this binding is considered invalid and will be ignored Required.", + "type": "string" } }, "type": "object" }, - "v1.ControllerRevision": { - "description": "ControllerRevision implements an immutable snapshot of state data. Clients are responsible for serializing and deserializing the objects that contain their internal state. Once a ControllerRevision has been successfully created, it can not be updated. The API Server will fail validation of all requests that attempt to mutate the Data field. ControllerRevisions may, however, be deleted. Note that, due to its use by both the DaemonSet and StatefulSet controllers for update and rollback, this object is beta. However, it may be subject to name and representation changes in future releases, and clients should not depend on its stability. It is primarily for internal use by controllers.", + "v1alpha1.MutatingAdmissionPolicyList": { + "description": "MutatingAdmissionPolicyList is a list of MutatingAdmissionPolicy.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, - "data": { - "description": "Data is the serialized representation of the state.", - "type": "object" + "items": { + "description": "List of ValidatingAdmissionPolicy.", + "items": { + "$ref": "#/definitions/v1alpha1.MutatingAdmissionPolicy" + }, + "type": "array" }, "kind": { "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", "type": "string" }, "metadata": { - "$ref": "#/definitions/v1.ObjectMeta", - "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" - }, - "revision": { - "description": "Revision indicates the revision of the state represented by Data.", - "format": "int64", - "type": "integer" + "$ref": "#/definitions/v1.ListMeta", + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds" } }, "required": [ - "revision" + "items" ], "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "apps", - "kind": "ControllerRevision", - "version": "v1" + "group": "admissionregistration.k8s.io", + "kind": "MutatingAdmissionPolicyList", + "version": "v1alpha1" } ] }, - "v1.ControllerRevisionList": { - "description": "ControllerRevisionList is a resource containing a list of ControllerRevision objects.", + "v1alpha1.MutatingAdmissionPolicySpec": { + "description": "MutatingAdmissionPolicySpec is the specification of the desired behavior of the admission policy.", "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "failurePolicy": { + "description": "failurePolicy defines how to handle failures for the admission policy. Failures can occur from CEL expression parse errors, type check errors, runtime errors and invalid or mis-configured policy definitions or bindings.\n\nA policy is invalid if paramKind refers to a non-existent Kind. A binding is invalid if paramRef.name refers to a non-existent resource.\n\nfailurePolicy does not define how validations that evaluate to false are handled.\n\nAllowed values are Ignore or Fail. Defaults to Fail.", "type": "string" }, - "items": { - "description": "Items is the list of ControllerRevisions", + "matchConditions": { + "description": "matchConditions is a list of conditions that must be met for a request to be validated. Match conditions filter requests that have already been matched by the matchConstraints. An empty list of matchConditions matches all requests. There are a maximum of 64 match conditions allowed.\n\nIf a parameter object is provided, it can be accessed via the `params` handle in the same manner as validation expressions.\n\nThe exact matching logic is (in order):\n 1. If ANY matchCondition evaluates to FALSE, the policy is skipped.\n 2. If ALL matchConditions evaluate to TRUE, the policy is evaluated.\n 3. If any matchCondition evaluates to an error (but none are FALSE):\n - If failurePolicy=Fail, reject the request\n - If failurePolicy=Ignore, the policy is skipped", "items": { - "$ref": "#/definitions/v1.ControllerRevision" + "$ref": "#/definitions/v1alpha1.MatchCondition" }, - "type": "array" + "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "matchConstraints": { + "$ref": "#/definitions/v1alpha1.MatchResources", + "description": "matchConstraints specifies what resources this policy is designed to validate. The MutatingAdmissionPolicy cares about a request if it matches _all_ Constraints. However, in order to prevent clusters from being put into an unstable state that cannot be recovered from via the API MutatingAdmissionPolicy cannot match MutatingAdmissionPolicy and MutatingAdmissionPolicyBinding. The CREATE, UPDATE and CONNECT operations are allowed. The DELETE operation may not be matched. '*' matches CREATE, UPDATE and CONNECT. Required." + }, + "mutations": { + "description": "mutations contain operations to perform on matching objects. mutations may not be empty; a minimum of one mutation is required. mutations are evaluated in order, and are reinvoked according to the reinvocationPolicy. The mutations of a policy are invoked for each binding of this policy and reinvocation of mutations occurs on a per binding basis.", + "items": { + "$ref": "#/definitions/v1alpha1.Mutation" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "paramKind": { + "$ref": "#/definitions/v1alpha1.ParamKind", + "description": "paramKind specifies the kind of resources used to parameterize this policy. If absent, there are no parameters for this policy and the param CEL variable will not be provided to validation expressions. If paramKind refers to a non-existent kind, this policy definition is mis-configured and the FailurePolicy is applied. If paramKind is specified but paramRef is unset in MutatingAdmissionPolicyBinding, the params variable will be null." + }, + "reinvocationPolicy": { + "description": "reinvocationPolicy indicates whether mutations may be called multiple times per MutatingAdmissionPolicyBinding as part of a single admission evaluation. Allowed values are \"Never\" and \"IfNeeded\".\n\nNever: These mutations will not be called more than once per binding in a single admission evaluation.\n\nIfNeeded: These mutations may be invoked more than once per binding for a single admission request and there is no guarantee of order with respect to other admission plugins, admission webhooks, bindings of this policy and admission policies. Mutations are only reinvoked when mutations change the object after this mutation is invoked. Required.", "type": "string" }, - "metadata": { - "$ref": "#/definitions/v1.ListMeta", - "description": "More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + "variables": { + "description": "variables contain definitions of variables that can be used in composition of other expressions. Each variable is defined as a named CEL expression. The variables defined here will be available under `variables` in other expressions of the policy except matchConditions because matchConditions are evaluated before the rest of the policy.\n\nThe expression of a variable can refer to other variables defined earlier in the list but not those after. Thus, variables must be sorted by the order of first appearance and acyclic.", + "items": { + "$ref": "#/definitions/v1alpha1.Variable" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + } + }, + "type": "object" + }, + "v1alpha1.Mutation": { + "description": "Mutation specifies the CEL expression which is used to apply the Mutation.", + "properties": { + "applyConfiguration": { + "$ref": "#/definitions/v1alpha1.ApplyConfiguration", + "description": "applyConfiguration defines the desired configuration values of an object. The configuration is applied to the admission object using [structured merge diff](https://github.com/kubernetes-sigs/structured-merge-diff). A CEL expression is used to create apply configuration." + }, + "jsonPatch": { + "$ref": "#/definitions/v1alpha1.JSONPatch", + "description": "jsonPatch defines a [JSON patch](https://jsonpatch.com/) operation to perform a mutation to the object. A CEL expression is used to create the JSON patch." + }, + "patchType": { + "description": "patchType indicates the patch strategy used. Allowed values are \"ApplyConfiguration\" and \"JSONPatch\". Required.", + "type": "string" } }, "required": [ - "items" + "patchType" ], - "type": "object", - "x-kubernetes-group-version-kind": [ - { - "group": "apps", - "kind": "ControllerRevisionList", - "version": "v1" + "type": "object" + }, + "v1alpha1.NamedRuleWithOperations": { + "description": "NamedRuleWithOperations is a tuple of Operations and Resources with ResourceNames.", + "properties": { + "apiGroups": { + "description": "APIGroups is the API groups the resources belong to. '*' is all groups. If '*' is present, the length of the slice must be one. Required.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "apiVersions": { + "description": "APIVersions is the API versions the resources belong to. '*' is all versions. If '*' is present, the length of the slice must be one. Required.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "operations": { + "description": "Operations is the operations the admission hook cares about - CREATE, UPDATE, DELETE, CONNECT or * for all of those operations and any future admission operations that are added. If '*' is present, the length of the slice must be one. Required.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "resourceNames": { + "description": "ResourceNames is an optional white list of names that the rule applies to. An empty set means that everything is allowed.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "resources": { + "description": "Resources is a list of resources this rule applies to.\n\nFor example: 'pods' means pods. 'pods/log' means the log subresource of pods. '*' means all resources, but not subresources. 'pods/*' means all subresources of pods. '*/scale' means all scale subresources. '*/*' means all resources and their subresources.\n\nIf wildcard is present, the validation rule will ensure resources do not overlap with each other.\n\nDepending on the enclosing object, subresources might not be allowed. Required.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "scope": { + "description": "scope specifies the scope of this rule. Valid values are \"Cluster\", \"Namespaced\", and \"*\" \"Cluster\" means that only cluster-scoped resources will match this rule. Namespace API objects are cluster-scoped. \"Namespaced\" means that only namespaced resources will match this rule. \"*\" means that there are no scope restrictions. Subresources match the scope of their parent resource. Default is \"*\".", + "type": "string" } - ] + }, + "type": "object", + "x-kubernetes-map-type": "atomic" }, - "v1.DaemonSet": { - "description": "DaemonSet represents the configuration of a daemon set.", + "v1alpha1.ParamKind": { + "description": "ParamKind is a tuple of Group Kind and Version.", "properties": { "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "description": "APIVersion is the API group version the resources belong to. In format of \"group/version\". Required.", "type": "string" }, "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "description": "Kind is the API kind the resources belong to. Required.", "type": "string" - }, - "metadata": { - "$ref": "#/definitions/v1.ObjectMeta", - "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" - }, - "spec": { - "$ref": "#/definitions/v1.DaemonSetSpec", - "description": "The desired behavior of this daemon set. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" - }, - "status": { - "$ref": "#/definitions/v1.DaemonSetStatus", - "description": "The current status of this daemon set. This data may be out of date by some window of time. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, "type": "object", - "x-kubernetes-group-version-kind": [ - { - "group": "apps", - "kind": "DaemonSet", - "version": "v1" - } - ] + "x-kubernetes-map-type": "atomic" }, - "v1.DaemonSetCondition": { - "description": "DaemonSetCondition describes the state of a DaemonSet at a certain point.", + "v1alpha1.ParamRef": { + "description": "ParamRef describes how to locate the params to be used as input to expressions of rules applied by a policy binding.", "properties": { - "lastTransitionTime": { - "description": "Last time the condition transitioned from one status to another.", - "format": "date-time", + "name": { + "description": "`name` is the name of the resource being referenced.\n\n`name` and `selector` are mutually exclusive properties. If one is set, the other must be unset.", "type": "string" }, - "message": { - "description": "A human readable message indicating details about the transition.", + "namespace": { + "description": "namespace is the namespace of the referenced resource. Allows limiting the search for params to a specific namespace. Applies to both `name` and `selector` fields.\n\nA per-namespace parameter may be used by specifying a namespace-scoped `paramKind` in the policy and leaving this field empty.\n\n- If `paramKind` is cluster-scoped, this field MUST be unset. Setting this field results in a configuration error.\n\n- If `paramKind` is namespace-scoped, the namespace of the object being evaluated for admission will be used when this field is left unset. Take care that if this is left empty the binding must not match any cluster-scoped resources, which will result in an error.", "type": "string" }, - "reason": { - "description": "The reason for the condition's last transition.", + "parameterNotFoundAction": { + "description": "`parameterNotFoundAction` controls the behavior of the binding when the resource exists, and name or selector is valid, but there are no parameters matched by the binding. If the value is set to `Allow`, then no matched parameters will be treated as successful validation by the binding. If set to `Deny`, then no matched parameters will be subject to the `failurePolicy` of the policy.\n\nAllowed values are `Allow` or `Deny` Default to `Deny`", "type": "string" }, - "status": { - "description": "Status of the condition, one of True, False, Unknown.", + "selector": { + "$ref": "#/definitions/v1.LabelSelector", + "description": "selector can be used to match multiple param objects based on their labels. Supply selector: {} to match all resources of the ParamKind.\n\nIf multiple params are found, they are all evaluated with the policy expressions and the results are ANDed together.\n\nOne of `name` or `selector` must be set, but `name` and `selector` are mutually exclusive properties. If one is set, the other must be unset." + } + }, + "type": "object", + "x-kubernetes-map-type": "atomic" + }, + "v1alpha1.Variable": { + "description": "Variable is the definition of a variable that is used for composition.", + "properties": { + "expression": { + "description": "Expression is the expression that will be evaluated as the value of the variable. The CEL expression has access to the same identifiers as the CEL expressions in Validation.", "type": "string" }, - "type": { - "description": "Type of DaemonSet condition.", + "name": { + "description": "Name is the name of the variable. The name must be a valid CEL identifier and unique among all variables. The variable can be accessed in other expressions through `variables` For example, if name is \"foo\", the variable will be available as `variables.foo`", "type": "string" } }, "required": [ - "type", - "status" + "name", + "expression" ], "type": "object" }, - "v1.DaemonSetList": { - "description": "DaemonSetList is a collection of daemon sets.", + "v1beta1.ApplyConfiguration": { + "description": "ApplyConfiguration defines the desired configuration values of an object.", "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "items": { - "description": "A list of daemon sets.", - "items": { - "$ref": "#/definitions/v1.DaemonSet" - }, - "type": "array" - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "expression": { + "description": "expression will be evaluated by CEL to create an apply configuration. ref: https://github.com/google/cel-spec\n\nApply configurations are declared in CEL using object initialization. For example, this CEL expression returns an apply configuration to set a single field:\n\n\tObject{\n\t spec: Object.spec{\n\t serviceAccountName: \"example\"\n\t }\n\t}\n\nApply configurations may not modify atomic structs, maps or arrays due to the risk of accidental deletion of values not included in the apply configuration.\n\nCEL expressions have access to the object types needed to create apply configurations:\n\n- 'Object' - CEL type of the resource object. - 'Object.' - CEL type of object field (such as 'Object.spec') - 'Object.....` - CEL type of nested field (such as 'Object.spec.containers')\n\nCEL expressions have access to the contents of the API request, organized into CEL variables as well as some other useful variables:\n\n- 'object' - The object from the incoming request. The value is null for DELETE requests. - 'oldObject' - The existing object. The value is null for CREATE requests. - 'request' - Attributes of the API request([ref](/pkg/apis/admission/types.go#AdmissionRequest)). - 'params' - Parameter resource referred to by the policy binding being evaluated. Only populated if the policy has a ParamKind. - 'namespaceObject' - The namespace object that the incoming object belongs to. The value is null for cluster-scoped resources. - 'variables' - Map of composited variables, from its name to its lazily evaluated value.\n For example, a variable named 'foo' can be accessed as 'variables.foo'.\n- 'authorizer' - A CEL Authorizer. May be used to perform authorization checks for the principal (user or service account) of the request.\n See https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz\n- 'authorizer.requestResource' - A CEL ResourceCheck constructed from the 'authorizer' and configured with the\n request resource.\n\nThe `apiVersion`, `kind`, `metadata.name` and `metadata.generateName` are always accessible from the root of the object. No other metadata properties are accessible.\n\nOnly property names of the form `[a-zA-Z_.-/][a-zA-Z0-9_.-/]*` are accessible. Required.", "type": "string" - }, - "metadata": { - "$ref": "#/definitions/v1.ListMeta", - "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" } }, - "required": [ - "items" - ], - "type": "object", - "x-kubernetes-group-version-kind": [ - { - "group": "apps", - "kind": "DaemonSetList", - "version": "v1" + "type": "object" + }, + "v1beta1.JSONPatch": { + "description": "JSONPatch defines a JSON Patch.", + "properties": { + "expression": { + "description": "expression will be evaluated by CEL to create a [JSON patch](https://jsonpatch.com/). ref: https://github.com/google/cel-spec\n\nexpression must return an array of JSONPatch values.\n\nFor example, this CEL expression returns a JSON patch to conditionally modify a value:\n\n\t [\n\t JSONPatch{op: \"test\", path: \"/spec/example\", value: \"Red\"},\n\t JSONPatch{op: \"replace\", path: \"/spec/example\", value: \"Green\"}\n\t ]\n\nTo define an object for the patch value, use Object types. For example:\n\n\t [\n\t JSONPatch{\n\t op: \"add\",\n\t path: \"/spec/selector\",\n\t value: Object.spec.selector{matchLabels: {\"environment\": \"test\"}}\n\t }\n\t ]\n\nTo use strings containing '/' and '~' as JSONPatch path keys, use \"jsonpatch.escapeKey\". For example:\n\n\t [\n\t JSONPatch{\n\t op: \"add\",\n\t path: \"/metadata/labels/\" + jsonpatch.escapeKey(\"example.com/environment\"),\n\t value: \"test\"\n\t },\n\t ]\n\nCEL expressions have access to the types needed to create JSON patches and objects:\n\n- 'JSONPatch' - CEL type of JSON Patch operations. JSONPatch has the fields 'op', 'from', 'path' and 'value'.\n See [JSON patch](https://jsonpatch.com/) for more details. The 'value' field may be set to any of: string,\n integer, array, map or object. If set, the 'path' and 'from' fields must be set to a\n [JSON pointer](https://datatracker.ietf.org/doc/html/rfc6901/) string, where the 'jsonpatch.escapeKey()' CEL\n function may be used to escape path keys containing '/' and '~'.\n- 'Object' - CEL type of the resource object. - 'Object.' - CEL type of object field (such as 'Object.spec') - 'Object.....` - CEL type of nested field (such as 'Object.spec.containers')\n\nCEL expressions have access to the contents of the API request, organized into CEL variables as well as some other useful variables:\n\n- 'object' - The object from the incoming request. The value is null for DELETE requests. - 'oldObject' - The existing object. The value is null for CREATE requests. - 'request' - Attributes of the API request([ref](/pkg/apis/admission/types.go#AdmissionRequest)). - 'params' - Parameter resource referred to by the policy binding being evaluated. Only populated if the policy has a ParamKind. - 'namespaceObject' - The namespace object that the incoming object belongs to. The value is null for cluster-scoped resources. - 'variables' - Map of composited variables, from its name to its lazily evaluated value.\n For example, a variable named 'foo' can be accessed as 'variables.foo'.\n- 'authorizer' - A CEL Authorizer. May be used to perform authorization checks for the principal (user or service account) of the request.\n See https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz\n- 'authorizer.requestResource' - A CEL ResourceCheck constructed from the 'authorizer' and configured with the\n request resource.\n\nCEL expressions have access to [Kubernetes CEL function libraries](https://kubernetes.io/docs/reference/using-api/cel/#cel-options-language-features-and-libraries) as well as:\n\n- 'jsonpatch.escapeKey' - Performs JSONPatch key escaping. '~' and '/' are escaped as '~0' and `~1' respectively).\n\nOnly property names of the form `[a-zA-Z_.-/][a-zA-Z0-9_.-/]*` are accessible. Required.", + "type": "string" } - ] + }, + "type": "object" }, - "v1.DaemonSetSpec": { - "description": "DaemonSetSpec is the specification of a daemon set.", + "v1beta1.MatchCondition": { + "description": "MatchCondition represents a condition which must be fulfilled for a request to be sent to a webhook.", "properties": { - "minReadySeconds": { - "description": "The minimum number of seconds for which a newly created DaemonSet pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready).", - "format": "int32", - "type": "integer" - }, - "revisionHistoryLimit": { - "description": "The number of old history to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified. Defaults to 10.", - "format": "int32", - "type": "integer" - }, - "selector": { - "$ref": "#/definitions/v1.LabelSelector", - "description": "A label query over pods that are managed by the daemon set. Must match in order to be controlled. It must match the pod template's labels. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors" - }, - "template": { - "$ref": "#/definitions/v1.PodTemplateSpec", - "description": "An object that describes the pod that will be created. The DaemonSet will create exactly one copy of this pod on every node that matches the template's node selector (or on every node if no node selector is specified). More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#pod-template" + "expression": { + "description": "Expression represents the expression which will be evaluated by CEL. Must evaluate to bool. CEL expressions have access to the contents of the AdmissionRequest and Authorizer, organized into CEL variables:\n\n'object' - The object from the incoming request. The value is null for DELETE requests. 'oldObject' - The existing object. The value is null for CREATE requests. 'request' - Attributes of the admission request(/pkg/apis/admission/types.go#AdmissionRequest). 'authorizer' - A CEL Authorizer. May be used to perform authorization checks for the principal (user or service account) of the request.\n See https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz\n'authorizer.requestResource' - A CEL ResourceCheck constructed from the 'authorizer' and configured with the\n request resource.\nDocumentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/\n\nRequired.", + "type": "string" }, - "updateStrategy": { - "$ref": "#/definitions/v1.DaemonSetUpdateStrategy", - "description": "An update strategy to replace existing DaemonSet pods with new pods." + "name": { + "description": "Name is an identifier for this match condition, used for strategic merging of MatchConditions, as well as providing an identifier for logging purposes. A good name should be descriptive of the associated expression. Name must be a qualified name consisting of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName', or 'my.name', or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]') with an optional DNS subdomain prefix and '/' (e.g. 'example.com/MyName')\n\nRequired.", + "type": "string" } }, "required": [ - "selector", - "template" + "name", + "expression" ], "type": "object" }, - "v1.DaemonSetStatus": { - "description": "DaemonSetStatus represents the current status of a daemon set.", + "v1beta1.MatchResources": { + "description": "MatchResources decides whether to run the admission control policy on an object based on whether it meets the match criteria. The exclude rules take precedence over include rules (if a resource matches both, it is excluded)", "properties": { - "collisionCount": { - "description": "Count of hash collisions for the DaemonSet. The DaemonSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision.", - "format": "int32", - "type": "integer" - }, - "conditions": { - "description": "Represents the latest available observations of a DaemonSet's current state.", + "excludeResourceRules": { + "description": "ExcludeResourceRules describes what operations on what resources/subresources the ValidatingAdmissionPolicy should not care about. The exclude rules take precedence over include rules (if a resource matches both, it is excluded)", "items": { - "$ref": "#/definitions/v1.DaemonSetCondition" + "$ref": "#/definitions/v1beta1.NamedRuleWithOperations" }, "type": "array", - "x-kubernetes-patch-merge-key": "type", - "x-kubernetes-patch-strategy": "merge" - }, - "currentNumberScheduled": { - "description": "The number of nodes that are running at least 1 daemon pod and are supposed to run the daemon pod. More info: https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/", - "format": "int32", - "type": "integer" - }, - "desiredNumberScheduled": { - "description": "The total number of nodes that should be running the daemon pod (including nodes correctly running the daemon pod). More info: https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/", - "format": "int32", - "type": "integer" - }, - "numberAvailable": { - "description": "The number of nodes that should be running the daemon pod and have one or more of the daemon pod running and available (ready for at least spec.minReadySeconds)", - "format": "int32", - "type": "integer" - }, - "numberMisscheduled": { - "description": "The number of nodes that are running the daemon pod, but are not supposed to run the daemon pod. More info: https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/", - "format": "int32", - "type": "integer" + "x-kubernetes-list-type": "atomic" }, - "numberReady": { - "description": "numberReady is the number of nodes that should be running the daemon pod and have one or more of the daemon pod running with a Ready Condition.", - "format": "int32", - "type": "integer" + "matchPolicy": { + "description": "matchPolicy defines how the \"MatchResources\" list is used to match incoming requests. Allowed values are \"Exact\" or \"Equivalent\".\n\n- Exact: match a request only if it exactly matches a specified rule. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, but \"rules\" only included `apiGroups:[\"apps\"], apiVersions:[\"v1\"], resources: [\"deployments\"]`, a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the ValidatingAdmissionPolicy.\n\n- Equivalent: match a request if modifies a resource listed in rules, even via another API group or version. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, and \"rules\" only included `apiGroups:[\"apps\"], apiVersions:[\"v1\"], resources: [\"deployments\"]`, a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the ValidatingAdmissionPolicy.\n\nDefaults to \"Equivalent\"", + "type": "string" }, - "numberUnavailable": { - "description": "The number of nodes that should be running the daemon pod and have none of the daemon pod running and available (ready for at least spec.minReadySeconds)", - "format": "int32", - "type": "integer" + "namespaceSelector": { + "$ref": "#/definitions/v1.LabelSelector", + "description": "NamespaceSelector decides whether to run the admission control policy on an object based on whether the namespace for that object matches the selector. If the object itself is a namespace, the matching is performed on object.metadata.labels. If the object is another cluster scoped resource, it never skips the policy.\n\nFor example, to run the webhook on any objects whose namespace is not associated with \"runlevel\" of \"0\" or \"1\"; you will set the selector as follows: \"namespaceSelector\": {\n \"matchExpressions\": [\n {\n \"key\": \"runlevel\",\n \"operator\": \"NotIn\",\n \"values\": [\n \"0\",\n \"1\"\n ]\n }\n ]\n}\n\nIf instead you want to only run the policy on any objects whose namespace is associated with the \"environment\" of \"prod\" or \"staging\"; you will set the selector as follows: \"namespaceSelector\": {\n \"matchExpressions\": [\n {\n \"key\": \"environment\",\n \"operator\": \"In\",\n \"values\": [\n \"prod\",\n \"staging\"\n ]\n }\n ]\n}\n\nSee https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ for more examples of label selectors.\n\nDefault to the empty LabelSelector, which matches everything." }, - "observedGeneration": { - "description": "The most recent generation observed by the daemon set controller.", - "format": "int64", - "type": "integer" + "objectSelector": { + "$ref": "#/definitions/v1.LabelSelector", + "description": "ObjectSelector decides whether to run the validation based on if the object has matching labels. objectSelector is evaluated against both the oldObject and newObject that would be sent to the cel validation, and is considered to match if either object matches the selector. A null object (oldObject in the case of create, or newObject in the case of delete) or an object that cannot have labels (like a DeploymentRollback or a PodProxyOptions object) is not considered to match. Use the object selector only if the webhook is opt-in, because end users may skip the admission webhook by setting the labels. Default to the empty LabelSelector, which matches everything." }, - "updatedNumberScheduled": { - "description": "The total number of nodes that are running updated daemon pod", - "format": "int32", - "type": "integer" + "resourceRules": { + "description": "ResourceRules describes what operations on what resources/subresources the ValidatingAdmissionPolicy matches. The policy cares about an operation if it matches _any_ Rule.", + "items": { + "$ref": "#/definitions/v1beta1.NamedRuleWithOperations" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" } }, - "required": [ - "currentNumberScheduled", - "numberMisscheduled", - "desiredNumberScheduled", - "numberReady" - ], - "type": "object" + "type": "object", + "x-kubernetes-map-type": "atomic" }, - "v1.DaemonSetUpdateStrategy": { - "description": "DaemonSetUpdateStrategy is a struct used to control the update strategy for a DaemonSet.", + "v1beta1.MutatingAdmissionPolicy": { + "description": "MutatingAdmissionPolicy describes the definition of an admission mutation policy that mutates the object coming into admission chain.", "properties": { - "rollingUpdate": { - "$ref": "#/definitions/v1.RollingUpdateDaemonSet", - "description": "Rolling update config params. Present only if type = \"RollingUpdate\"." + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" }, - "type": { - "description": "Type of daemon set update. Can be \"RollingUpdate\" or \"OnDelete\". Default is RollingUpdate.\n\n", + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", "type": "string" + }, + "metadata": { + "$ref": "#/definitions/v1.ObjectMeta", + "description": "Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata." + }, + "spec": { + "$ref": "#/definitions/v1beta1.MutatingAdmissionPolicySpec", + "description": "Specification of the desired behavior of the MutatingAdmissionPolicy." } }, - "type": "object" + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "admissionregistration.k8s.io", + "kind": "MutatingAdmissionPolicy", + "version": "v1beta1" + } + ] }, - "v1.Deployment": { - "description": "Deployment enables declarative updates for Pods and ReplicaSets.", + "v1beta1.MutatingAdmissionPolicyBinding": { + "description": "MutatingAdmissionPolicyBinding binds the MutatingAdmissionPolicy with parametrized resources. MutatingAdmissionPolicyBinding and the optional parameter resource together define how cluster administrators configure policies for clusters.\n\nFor a given admission request, each binding will cause its policy to be evaluated N times, where N is 1 for policies/bindings that don't use params, otherwise N is the number of parameters selected by the binding. Each evaluation is constrained by a [runtime cost budget](https://kubernetes.io/docs/reference/using-api/cel/#runtime-cost-budget).\n\nAdding/removing policies, bindings, or params can not affect whether a given (policy, binding, param) combination is within its own CEL budget.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", @@ -803,73 +1378,86 @@ }, "metadata": { "$ref": "#/definitions/v1.ObjectMeta", - "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + "description": "Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata." }, "spec": { - "$ref": "#/definitions/v1.DeploymentSpec", - "description": "Specification of the desired behavior of the Deployment." - }, - "status": { - "$ref": "#/definitions/v1.DeploymentStatus", - "description": "Most recently observed status of the Deployment." + "$ref": "#/definitions/v1beta1.MutatingAdmissionPolicyBindingSpec", + "description": "Specification of the desired behavior of the MutatingAdmissionPolicyBinding." } }, "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "apps", - "kind": "Deployment", - "version": "v1" + "group": "admissionregistration.k8s.io", + "kind": "MutatingAdmissionPolicyBinding", + "version": "v1beta1" } ] }, - "v1.DeploymentCondition": { - "description": "DeploymentCondition describes the state of a deployment at a certain point.", + "v1beta1.MutatingAdmissionPolicyBindingList": { + "description": "MutatingAdmissionPolicyBindingList is a list of MutatingAdmissionPolicyBinding.", "properties": { - "lastTransitionTime": { - "description": "Last time the condition transitioned from one status to another.", - "format": "date-time", + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, - "lastUpdateTime": { - "description": "The last time this condition was updated.", - "format": "date-time", - "type": "string" + "items": { + "description": "List of PolicyBinding.", + "items": { + "$ref": "#/definitions/v1beta1.MutatingAdmissionPolicyBinding" + }, + "type": "array" }, - "message": { - "description": "A human readable message indicating details about the transition.", + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", "type": "string" }, - "reason": { - "description": "The reason for the condition's last transition.", - "type": "string" + "metadata": { + "$ref": "#/definitions/v1.ListMeta", + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds" + } + }, + "required": [ + "items" + ], + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "admissionregistration.k8s.io", + "kind": "MutatingAdmissionPolicyBindingList", + "version": "v1beta1" + } + ] + }, + "v1beta1.MutatingAdmissionPolicyBindingSpec": { + "description": "MutatingAdmissionPolicyBindingSpec is the specification of the MutatingAdmissionPolicyBinding.", + "properties": { + "matchResources": { + "$ref": "#/definitions/v1beta1.MatchResources", + "description": "matchResources limits what resources match this binding and may be mutated by it. Note that if matchResources matches a resource, the resource must also match a policy's matchConstraints and matchConditions before the resource may be mutated. When matchResources is unset, it does not constrain resource matching, and only the policy's matchConstraints and matchConditions must match for the resource to be mutated. Additionally, matchResources.resourceRules are optional and do not constraint matching when unset. Note that this is differs from MutatingAdmissionPolicy matchConstraints, where resourceRules are required. The CREATE, UPDATE and CONNECT operations are allowed. The DELETE operation may not be matched. '*' matches CREATE, UPDATE and CONNECT." }, - "status": { - "description": "Status of the condition, one of True, False, Unknown.", - "type": "string" + "paramRef": { + "$ref": "#/definitions/v1beta1.ParamRef", + "description": "paramRef specifies the parameter resource used to configure the admission control policy. It should point to a resource of the type specified in spec.ParamKind of the bound MutatingAdmissionPolicy. If the policy specifies a ParamKind and the resource referred to by ParamRef does not exist, this binding is considered mis-configured and the FailurePolicy of the MutatingAdmissionPolicy applied. If the policy does not specify a ParamKind then this field is ignored, and the rules are evaluated without a param." }, - "type": { - "description": "Type of deployment condition.", + "policyName": { + "description": "policyName references a MutatingAdmissionPolicy name which the MutatingAdmissionPolicyBinding binds to. If the referenced resource does not exist, this binding is considered invalid and will be ignored Required.", "type": "string" } }, - "required": [ - "type", - "status" - ], "type": "object" }, - "v1.DeploymentList": { - "description": "DeploymentList is a list of Deployments.", + "v1beta1.MutatingAdmissionPolicyList": { + "description": "MutatingAdmissionPolicyList is a list of MutatingAdmissionPolicy.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, "items": { - "description": "Items is the list of Deployments.", + "description": "List of ValidatingAdmissionPolicy.", "items": { - "$ref": "#/definitions/v1.Deployment" + "$ref": "#/definitions/v1beta1.MutatingAdmissionPolicy" }, "type": "array" }, @@ -879,7 +1467,7 @@ }, "metadata": { "$ref": "#/definitions/v1.ListMeta", - "description": "Standard list metadata." + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds" } }, "required": [ @@ -888,125 +1476,224 @@ "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "apps", - "kind": "DeploymentList", - "version": "v1" + "group": "admissionregistration.k8s.io", + "kind": "MutatingAdmissionPolicyList", + "version": "v1beta1" } ] }, - "v1.DeploymentSpec": { - "description": "DeploymentSpec is the specification of the desired behavior of the Deployment.", + "v1beta1.MutatingAdmissionPolicySpec": { + "description": "MutatingAdmissionPolicySpec is the specification of the desired behavior of the admission policy.", "properties": { - "minReadySeconds": { - "description": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)", - "format": "int32", - "type": "integer" + "failurePolicy": { + "description": "failurePolicy defines how to handle failures for the admission policy. Failures can occur from CEL expression parse errors, type check errors, runtime errors and invalid or mis-configured policy definitions or bindings.\n\nA policy is invalid if paramKind refers to a non-existent Kind. A binding is invalid if paramRef.name refers to a non-existent resource.\n\nfailurePolicy does not define how validations that evaluate to false are handled.\n\nAllowed values are Ignore or Fail. Defaults to Fail.", + "type": "string" }, - "paused": { - "description": "Indicates that the deployment is paused.", - "type": "boolean" + "matchConditions": { + "description": "matchConditions is a list of conditions that must be met for a request to be validated. Match conditions filter requests that have already been matched by the matchConstraints. An empty list of matchConditions matches all requests. There are a maximum of 64 match conditions allowed.\n\nIf a parameter object is provided, it can be accessed via the `params` handle in the same manner as validation expressions.\n\nThe exact matching logic is (in order):\n 1. If ANY matchCondition evaluates to FALSE, the policy is skipped.\n 2. If ALL matchConditions evaluate to TRUE, the policy is evaluated.\n 3. If any matchCondition evaluates to an error (but none are FALSE):\n - If failurePolicy=Fail, reject the request\n - If failurePolicy=Ignore, the policy is skipped", + "items": { + "$ref": "#/definitions/v1beta1.MatchCondition" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" }, - "progressDeadlineSeconds": { - "description": "The maximum time in seconds for a deployment to make progress before it is considered to be failed. The deployment controller will continue to process failed deployments and a condition with a ProgressDeadlineExceeded reason will be surfaced in the deployment status. Note that progress will not be estimated during the time a deployment is paused. Defaults to 600s.", - "format": "int32", - "type": "integer" + "matchConstraints": { + "$ref": "#/definitions/v1beta1.MatchResources", + "description": "matchConstraints specifies what resources this policy is designed to validate. The MutatingAdmissionPolicy cares about a request if it matches _all_ Constraints. However, in order to prevent clusters from being put into an unstable state that cannot be recovered from via the API MutatingAdmissionPolicy cannot match MutatingAdmissionPolicy and MutatingAdmissionPolicyBinding. The CREATE, UPDATE and CONNECT operations are allowed. The DELETE operation may not be matched. '*' matches CREATE, UPDATE and CONNECT. Required." }, - "replicas": { - "description": "Number of desired pods. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1.", - "format": "int32", - "type": "integer" + "mutations": { + "description": "mutations contain operations to perform on matching objects. mutations may not be empty; a minimum of one mutation is required. mutations are evaluated in order, and are reinvoked according to the reinvocationPolicy. The mutations of a policy are invoked for each binding of this policy and reinvocation of mutations occurs on a per binding basis.", + "items": { + "$ref": "#/definitions/v1beta1.Mutation" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" }, - "revisionHistoryLimit": { - "description": "The number of old ReplicaSets to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified. Defaults to 10.", - "format": "int32", - "type": "integer" + "paramKind": { + "$ref": "#/definitions/v1beta1.ParamKind", + "description": "paramKind specifies the kind of resources used to parameterize this policy. If absent, there are no parameters for this policy and the param CEL variable will not be provided to validation expressions. If paramKind refers to a non-existent kind, this policy definition is mis-configured and the FailurePolicy is applied. If paramKind is specified but paramRef is unset in MutatingAdmissionPolicyBinding, the params variable will be null." }, - "selector": { - "$ref": "#/definitions/v1.LabelSelector", - "description": "Label selector for pods. Existing ReplicaSets whose pods are selected by this will be the ones affected by this deployment. It must match the pod template's labels." + "reinvocationPolicy": { + "description": "reinvocationPolicy indicates whether mutations may be called multiple times per MutatingAdmissionPolicyBinding as part of a single admission evaluation. Allowed values are \"Never\" and \"IfNeeded\".\n\nNever: These mutations will not be called more than once per binding in a single admission evaluation.\n\nIfNeeded: These mutations may be invoked more than once per binding for a single admission request and there is no guarantee of order with respect to other admission plugins, admission webhooks, bindings of this policy and admission policies. Mutations are only reinvoked when mutations change the object after this mutation is invoked. Required.", + "type": "string" }, - "strategy": { - "$ref": "#/definitions/v1.DeploymentStrategy", - "description": "The deployment strategy to use to replace existing pods with new ones.", - "x-kubernetes-patch-strategy": "retainKeys" + "variables": { + "description": "variables contain definitions of variables that can be used in composition of other expressions. Each variable is defined as a named CEL expression. The variables defined here will be available under `variables` in other expressions of the policy except matchConditions because matchConditions are evaluated before the rest of the policy.\n\nThe expression of a variable can refer to other variables defined earlier in the list but not those after. Thus, variables must be sorted by the order of first appearance and acyclic.", + "items": { + "$ref": "#/definitions/v1beta1.Variable" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + } + }, + "type": "object" + }, + "v1beta1.Mutation": { + "description": "Mutation specifies the CEL expression which is used to apply the Mutation.", + "properties": { + "applyConfiguration": { + "$ref": "#/definitions/v1beta1.ApplyConfiguration", + "description": "applyConfiguration defines the desired configuration values of an object. The configuration is applied to the admission object using [structured merge diff](https://github.com/kubernetes-sigs/structured-merge-diff). A CEL expression is used to create apply configuration." }, - "template": { - "$ref": "#/definitions/v1.PodTemplateSpec", - "description": "Template describes the pods that will be created." + "jsonPatch": { + "$ref": "#/definitions/v1beta1.JSONPatch", + "description": "jsonPatch defines a [JSON patch](https://jsonpatch.com/) operation to perform a mutation to the object. A CEL expression is used to create the JSON patch." + }, + "patchType": { + "description": "patchType indicates the patch strategy used. Allowed values are \"ApplyConfiguration\" and \"JSONPatch\". Required.", + "type": "string" } }, "required": [ - "selector", - "template" + "patchType" ], "type": "object" }, - "v1.DeploymentStatus": { - "description": "DeploymentStatus is the most recently observed status of the Deployment.", + "v1beta1.NamedRuleWithOperations": { + "description": "NamedRuleWithOperations is a tuple of Operations and Resources with ResourceNames.", "properties": { - "availableReplicas": { - "description": "Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.", - "format": "int32", - "type": "integer" - }, - "collisionCount": { - "description": "Count of hash collisions for the Deployment. The Deployment controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ReplicaSet.", - "format": "int32", - "type": "integer" + "apiGroups": { + "description": "APIGroups is the API groups the resources belong to. '*' is all groups. If '*' is present, the length of the slice must be one. Required.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" }, - "conditions": { - "description": "Represents the latest available observations of a deployment's current state.", + "apiVersions": { + "description": "APIVersions is the API versions the resources belong to. '*' is all versions. If '*' is present, the length of the slice must be one. Required.", "items": { - "$ref": "#/definitions/v1.DeploymentCondition" + "type": "string" }, "type": "array", - "x-kubernetes-patch-merge-key": "type", - "x-kubernetes-patch-strategy": "merge" + "x-kubernetes-list-type": "atomic" }, - "observedGeneration": { - "description": "The generation observed by the deployment controller.", - "format": "int64", - "type": "integer" + "operations": { + "description": "Operations is the operations the admission hook cares about - CREATE, UPDATE, DELETE, CONNECT or * for all of those operations and any future admission operations that are added. If '*' is present, the length of the slice must be one. Required.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" }, - "readyReplicas": { - "description": "readyReplicas is the number of pods targeted by this Deployment with a Ready Condition.", - "format": "int32", - "type": "integer" + "resourceNames": { + "description": "ResourceNames is an optional white list of names that the rule applies to. An empty set means that everything is allowed.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" }, - "replicas": { - "description": "Total number of non-terminated pods targeted by this deployment (their labels match the selector).", - "format": "int32", - "type": "integer" + "resources": { + "description": "Resources is a list of resources this rule applies to.\n\nFor example: 'pods' means pods. 'pods/log' means the log subresource of pods. '*' means all resources, but not subresources. 'pods/*' means all subresources of pods. '*/scale' means all scale subresources. '*/*' means all resources and their subresources.\n\nIf wildcard is present, the validation rule will ensure resources do not overlap with each other.\n\nDepending on the enclosing object, subresources might not be allowed. Required.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" }, - "unavailableReplicas": { - "description": "Total number of unavailable pods targeted by this deployment. This is the total number of pods that are still required for the deployment to have 100% available capacity. They may either be pods that are running but not yet available or pods that still have not been created.", - "format": "int32", - "type": "integer" + "scope": { + "description": "scope specifies the scope of this rule. Valid values are \"Cluster\", \"Namespaced\", and \"*\" \"Cluster\" means that only cluster-scoped resources will match this rule. Namespace API objects are cluster-scoped. \"Namespaced\" means that only namespaced resources will match this rule. \"*\" means that there are no scope restrictions. Subresources match the scope of their parent resource. Default is \"*\".", + "type": "string" + } + }, + "type": "object", + "x-kubernetes-map-type": "atomic" + }, + "v1beta1.ParamKind": { + "description": "ParamKind is a tuple of Group Kind and Version.", + "properties": { + "apiVersion": { + "description": "APIVersion is the API group version the resources belong to. In format of \"group/version\". Required.", + "type": "string" }, - "updatedReplicas": { - "description": "Total number of non-terminated pods targeted by this deployment that have the desired template spec.", - "format": "int32", - "type": "integer" + "kind": { + "description": "Kind is the API kind the resources belong to. Required.", + "type": "string" } }, - "type": "object" + "type": "object", + "x-kubernetes-map-type": "atomic" }, - "v1.DeploymentStrategy": { - "description": "DeploymentStrategy describes how to replace existing pods with new ones.", + "v1beta1.ParamRef": { + "description": "ParamRef describes how to locate the params to be used as input to expressions of rules applied by a policy binding.", "properties": { - "rollingUpdate": { - "$ref": "#/definitions/v1.RollingUpdateDeployment", - "description": "Rolling update config params. Present only if DeploymentStrategyType = RollingUpdate." + "name": { + "description": "name is the name of the resource being referenced.\n\nOne of `name` or `selector` must be set, but `name` and `selector` are mutually exclusive properties. If one is set, the other must be unset.\n\nA single parameter used for all admission requests can be configured by setting the `name` field, leaving `selector` blank, and setting namespace if `paramKind` is namespace-scoped.", + "type": "string" }, - "type": { - "description": "Type of deployment. Can be \"Recreate\" or \"RollingUpdate\". Default is RollingUpdate.\n\n", + "namespace": { + "description": "namespace is the namespace of the referenced resource. Allows limiting the search for params to a specific namespace. Applies to both `name` and `selector` fields.\n\nA per-namespace parameter may be used by specifying a namespace-scoped `paramKind` in the policy and leaving this field empty.\n\n- If `paramKind` is cluster-scoped, this field MUST be unset. Setting this field results in a configuration error.\n\n- If `paramKind` is namespace-scoped, the namespace of the object being evaluated for admission will be used when this field is left unset. Take care that if this is left empty the binding must not match any cluster-scoped resources, which will result in an error.", + "type": "string" + }, + "parameterNotFoundAction": { + "description": "`parameterNotFoundAction` controls the behavior of the binding when the resource exists, and name or selector is valid, but there are no parameters matched by the binding. If the value is set to `Allow`, then no matched parameters will be treated as successful validation by the binding. If set to `Deny`, then no matched parameters will be subject to the `failurePolicy` of the policy.\n\nAllowed values are `Allow` or `Deny`\n\nRequired", + "type": "string" + }, + "selector": { + "$ref": "#/definitions/v1.LabelSelector", + "description": "selector can be used to match multiple param objects based on their labels. Supply selector: {} to match all resources of the ParamKind.\n\nIf multiple params are found, they are all evaluated with the policy expressions and the results are ANDed together.\n\nOne of `name` or `selector` must be set, but `name` and `selector` are mutually exclusive properties. If one is set, the other must be unset." + } + }, + "type": "object", + "x-kubernetes-map-type": "atomic" + }, + "v1beta1.Variable": { + "description": "Variable is the definition of a variable that is used for composition. A variable is defined as a named expression.", + "properties": { + "expression": { + "description": "Expression is the expression that will be evaluated as the value of the variable. The CEL expression has access to the same identifiers as the CEL expressions in Validation.", + "type": "string" + }, + "name": { + "description": "Name is the name of the variable. The name must be a valid CEL identifier and unique among all variables. The variable can be accessed in other expressions through `variables` For example, if name is \"foo\", the variable will be available as `variables.foo`", + "type": "string" + } + }, + "required": [ + "name", + "expression" + ], + "type": "object", + "x-kubernetes-map-type": "atomic" + }, + "v1alpha1.ServerStorageVersion": { + "description": "An API server instance reports the version it can decode and the version it encodes objects to when persisting objects in the backend.", + "properties": { + "apiServerID": { + "description": "The ID of the reporting API server.", + "type": "string" + }, + "decodableVersions": { + "description": "The API server can decode objects encoded in these versions. The encodingVersion must be included in the decodableVersions.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "set" + }, + "encodingVersion": { + "description": "The API server encodes the object to this version when persisting it in the backend (e.g., etcd).", "type": "string" + }, + "servedVersions": { + "description": "The API server can serve these versions. DecodableVersions must include all ServedVersions.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "set" } }, "type": "object" }, - "v1.ReplicaSet": { - "description": "ReplicaSet ensures that a specified number of pod replicas are running at any given time.", + "v1alpha1.StorageVersion": { + "description": "Storage version of a specific resource.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", @@ -1018,31 +1705,35 @@ }, "metadata": { "$ref": "#/definitions/v1.ObjectMeta", - "description": "If the Labels of a ReplicaSet are empty, they are defaulted to be the same as the Pod(s) that the ReplicaSet manages. Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + "description": "The name is .." }, "spec": { - "$ref": "#/definitions/v1.ReplicaSetSpec", - "description": "Spec defines the specification of the desired behavior of the ReplicaSet. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" + "description": "Spec is an empty spec. It is here to comply with Kubernetes API style.", + "type": "object" }, "status": { - "$ref": "#/definitions/v1.ReplicaSetStatus", - "description": "Status is the most recently observed status of the ReplicaSet. This data may be out of date by some window of time. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" + "$ref": "#/definitions/v1alpha1.StorageVersionStatus", + "description": "API server instances report the version they can decode and the version they encode objects to when persisting objects in the backend." } }, + "required": [ + "spec", + "status" + ], "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "apps", - "kind": "ReplicaSet", - "version": "v1" + "group": "internal.apiserver.k8s.io", + "kind": "StorageVersion", + "version": "v1alpha1" } ] }, - "v1.ReplicaSetCondition": { - "description": "ReplicaSetCondition describes the state of a replica set at a certain point.", + "v1alpha1.StorageVersionCondition": { + "description": "Describes the state of the storageVersion at a certain point.", "properties": { "lastTransitionTime": { - "description": "The last time the condition transitioned from one status to another.", + "description": "Last time the condition transitioned from one status to another.", "format": "date-time", "type": "string" }, @@ -1050,6 +1741,11 @@ "description": "A human readable message indicating details about the transition.", "type": "string" }, + "observedGeneration": { + "description": "If set, this represents the .metadata.generation that the condition was set based upon.", + "format": "int64", + "type": "integer" + }, "reason": { "description": "The reason for the condition's last transition.", "type": "string" @@ -1059,27 +1755,29 @@ "type": "string" }, "type": { - "description": "Type of replica set condition.", + "description": "Type of the condition.", "type": "string" } }, "required": [ "type", - "status" + "status", + "reason", + "message" ], "type": "object" }, - "v1.ReplicaSetList": { - "description": "ReplicaSetList is a collection of ReplicaSets.", + "v1alpha1.StorageVersionList": { + "description": "A list of StorageVersions.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, "items": { - "description": "List of ReplicaSets. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller", + "description": "Items holds a list of StorageVersion", "items": { - "$ref": "#/definitions/v1.ReplicaSet" + "$ref": "#/definitions/v1alpha1.StorageVersion" }, "type": "array" }, @@ -1089,7 +1787,7 @@ }, "metadata": { "$ref": "#/definitions/v1.ListMeta", - "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds" + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" } }, "required": [ @@ -1098,127 +1796,118 @@ "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "apps", - "kind": "ReplicaSetList", - "version": "v1" + "group": "internal.apiserver.k8s.io", + "kind": "StorageVersionList", + "version": "v1alpha1" } ] }, - "v1.ReplicaSetSpec": { - "description": "ReplicaSetSpec is the specification of a ReplicaSet.", + "v1alpha1.StorageVersionStatus": { + "description": "API server instances report the versions they can decode and the version they encode objects to when persisting objects in the backend.", "properties": { - "minReadySeconds": { - "description": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)", - "format": "int32", - "type": "integer" - }, - "replicas": { - "description": "Replicas is the number of desired replicas. This is a pointer to distinguish between explicit zero and unspecified. Defaults to 1. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/#what-is-a-replicationcontroller", - "format": "int32", - "type": "integer" + "commonEncodingVersion": { + "description": "If all API server instances agree on the same encoding storage version, then this field is set to that version. Otherwise this field is left empty. API servers should finish updating its storageVersionStatus entry before serving write operations, so that this field will be in sync with the reality.", + "type": "string" }, - "selector": { - "$ref": "#/definitions/v1.LabelSelector", - "description": "Selector is a label query over pods that should match the replica count. Label keys and values that must match in order to be controlled by this replica set. It must match the pod template's labels. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors" + "conditions": { + "description": "The latest available observations of the storageVersion's state.", + "items": { + "$ref": "#/definitions/v1alpha1.StorageVersionCondition" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map" }, - "template": { - "$ref": "#/definitions/v1.PodTemplateSpec", - "description": "Template is the object that describes the pod that will be created if insufficient replicas are detected. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#pod-template" + "storageVersions": { + "description": "The reported versions per API server instance.", + "items": { + "$ref": "#/definitions/v1alpha1.ServerStorageVersion" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "apiServerID" + ], + "x-kubernetes-list-type": "map" } }, - "required": [ - "selector" - ], "type": "object" }, - "v1.ReplicaSetStatus": { - "description": "ReplicaSetStatus represents the current status of a ReplicaSet.", + "v1.ControllerRevision": { + "description": "ControllerRevision implements an immutable snapshot of state data. Clients are responsible for serializing and deserializing the objects that contain their internal state. Once a ControllerRevision has been successfully created, it can not be updated. The API Server will fail validation of all requests that attempt to mutate the Data field. ControllerRevisions may, however, be deleted. Note that, due to its use by both the DaemonSet and StatefulSet controllers for update and rollback, this object is beta. However, it may be subject to name and representation changes in future releases, and clients should not depend on its stability. It is primarily for internal use by controllers.", "properties": { - "availableReplicas": { - "description": "The number of available replicas (ready for at least minReadySeconds) for this replica set.", - "format": "int32", - "type": "integer" - }, - "conditions": { - "description": "Represents the latest available observations of a replica set's current state.", - "items": { - "$ref": "#/definitions/v1.ReplicaSetCondition" - }, - "type": "array", - "x-kubernetes-patch-merge-key": "type", - "x-kubernetes-patch-strategy": "merge" + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" }, - "fullyLabeledReplicas": { - "description": "The number of pods that have labels matching the labels of the pod template of the replicaset.", - "format": "int32", - "type": "integer" + "data": { + "description": "Data is the serialized representation of the state.", + "type": "object" }, - "observedGeneration": { - "description": "ObservedGeneration reflects the generation of the most recently observed ReplicaSet.", - "format": "int64", - "type": "integer" + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" }, - "readyReplicas": { - "description": "readyReplicas is the number of pods targeted by this ReplicaSet with a Ready Condition.", - "format": "int32", - "type": "integer" + "metadata": { + "$ref": "#/definitions/v1.ObjectMeta", + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" }, - "replicas": { - "description": "Replicas is the most recently oberved number of replicas. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/#what-is-a-replicationcontroller", - "format": "int32", + "revision": { + "description": "Revision indicates the revision of the state represented by Data.", + "format": "int64", "type": "integer" } }, "required": [ - "replicas" + "revision" ], - "type": "object" - }, - "v1.RollingUpdateDaemonSet": { - "description": "Spec to control the desired behavior of daemon set rolling update.", - "properties": { - "maxSurge": { - "$ref": "#/definitions/intstr.IntOrString", - "description": "The maximum number of nodes with an existing available DaemonSet pod that can have an updated DaemonSet pod during during an update. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). This can not be 0 if MaxUnavailable is 0. Absolute number is calculated from percentage by rounding up to a minimum of 1. Default value is 0. Example: when this is set to 30%, at most 30% of the total number of nodes that should be running the daemon pod (i.e. status.desiredNumberScheduled) can have their a new pod created before the old pod is marked as deleted. The update starts by launching new pods on 30% of nodes. Once an updated pod is available (Ready for at least minReadySeconds) the old DaemonSet pod on that node is marked deleted. If the old pod becomes unavailable for any reason (Ready transitions to false, is evicted, or is drained) an updated pod is immediatedly created on that node without considering surge limits. Allowing surge implies the possibility that the resources consumed by the daemonset on any given node can double if the readiness check fails, and so resource intensive daemonsets should take into account that they may cause evictions during disruption." - }, - "maxUnavailable": { - "$ref": "#/definitions/intstr.IntOrString", - "description": "The maximum number of DaemonSet pods that can be unavailable during the update. Value can be an absolute number (ex: 5) or a percentage of total number of DaemonSet pods at the start of the update (ex: 10%). Absolute number is calculated from percentage by rounding up. This cannot be 0 if MaxSurge is 0 Default value is 1. Example: when this is set to 30%, at most 30% of the total number of nodes that should be running the daemon pod (i.e. status.desiredNumberScheduled) can have their pods stopped for an update at any given time. The update starts by stopping at most 30% of those DaemonSet pods and then brings up new DaemonSet pods in their place. Once the new pods are available, it then proceeds onto other DaemonSet pods, thus ensuring that at least 70% of original number of DaemonSet pods are available at all times during the update." + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "apps", + "kind": "ControllerRevision", + "version": "v1" } - }, - "type": "object" + ] }, - "v1.RollingUpdateDeployment": { - "description": "Spec to control the desired behavior of rolling update.", + "v1.ControllerRevisionList": { + "description": "ControllerRevisionList is a resource containing a list of ControllerRevision objects.", "properties": { - "maxSurge": { - "$ref": "#/definitions/intstr.IntOrString", - "description": "The maximum number of pods that can be scheduled above the desired number of pods. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). This can not be 0 if MaxUnavailable is 0. Absolute number is calculated from percentage by rounding up. Defaults to 25%. Example: when this is set to 30%, the new ReplicaSet can be scaled up immediately when the rolling update starts, such that the total number of old and new pods do not exceed 130% of desired pods. Once old pods have been killed, new ReplicaSet can be scaled up further, ensuring that total number of pods running at any time during the update is at most 130% of desired pods." + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" }, - "maxUnavailable": { - "$ref": "#/definitions/intstr.IntOrString", - "description": "The maximum number of pods that can be unavailable during the update. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). Absolute number is calculated from percentage by rounding down. This can not be 0 if MaxSurge is 0. Defaults to 25%. Example: when this is set to 30%, the old ReplicaSet can be scaled down to 70% of desired pods immediately when the rolling update starts. Once new pods are ready, old ReplicaSet can be scaled down further, followed by scaling up the new ReplicaSet, ensuring that the total number of pods available at all times during the update is at least 70% of desired pods." - } - }, - "type": "object" - }, - "v1.RollingUpdateStatefulSetStrategy": { - "description": "RollingUpdateStatefulSetStrategy is used to communicate parameter for RollingUpdateStatefulSetStrategyType.", - "properties": { - "maxUnavailable": { - "$ref": "#/definitions/intstr.IntOrString", - "description": "The maximum number of pods that can be unavailable during the update. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). Absolute number is calculated from percentage by rounding up. This can not be 0. Defaults to 1. This field is alpha-level and is only honored by servers that enable the MaxUnavailableStatefulSet feature. The field applies to all pods in the range 0 to Replicas-1. That means if there is any unavailable pod in the range 0 to Replicas-1, it will be counted towards MaxUnavailable." + "items": { + "description": "Items is the list of ControllerRevisions", + "items": { + "$ref": "#/definitions/v1.ControllerRevision" + }, + "type": "array" }, - "partition": { - "description": "Partition indicates the ordinal at which the StatefulSet should be partitioned for updates. During a rolling update, all pods from ordinal Replicas-1 to Partition are updated. All pods from ordinal Partition-1 to 0 remain untouched. This is helpful in being able to do a canary based deployment. The default value is 0.", - "format": "int32", - "type": "integer" + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/v1.ListMeta", + "description": "More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" } }, - "type": "object" + "required": [ + "items" + ], + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "apps", + "kind": "ControllerRevisionList", + "version": "v1" + } + ] }, - "v1.StatefulSet": { - "description": "StatefulSet represents a set of pods with consistent identities. Identities are defined as:\n - Network: A single stable DNS and hostname.\n - Storage: As many VolumeClaims as requested.\n\nThe StatefulSet guarantees that a given network identity will always map to the same storage identity.", + "v1.DaemonSet": { + "description": "DaemonSet represents the configuration of a daemon set.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", @@ -1233,25 +1922,25 @@ "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" }, "spec": { - "$ref": "#/definitions/v1.StatefulSetSpec", - "description": "Spec defines the desired identities of pods in this set." + "$ref": "#/definitions/v1.DaemonSetSpec", + "description": "The desired behavior of this daemon set. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" }, "status": { - "$ref": "#/definitions/v1.StatefulSetStatus", - "description": "Status is the current status of Pods in this StatefulSet. This data may be out of date by some window of time." + "$ref": "#/definitions/v1.DaemonSetStatus", + "description": "The current status of this daemon set. This data may be out of date by some window of time. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, "type": "object", "x-kubernetes-group-version-kind": [ { "group": "apps", - "kind": "StatefulSet", + "kind": "DaemonSet", "version": "v1" } ] }, - "v1.StatefulSetCondition": { - "description": "StatefulSetCondition describes the state of a statefulset at a certain point.", + "v1.DaemonSetCondition": { + "description": "DaemonSetCondition describes the state of a DaemonSet at a certain point.", "properties": { "lastTransitionTime": { "description": "Last time the condition transitioned from one status to another.", @@ -1271,7 +1960,7 @@ "type": "string" }, "type": { - "description": "Type of statefulset condition.", + "description": "Type of DaemonSet condition.", "type": "string" } }, @@ -1281,17 +1970,17 @@ ], "type": "object" }, - "v1.StatefulSetList": { - "description": "StatefulSetList is a collection of StatefulSets.", + "v1.DaemonSetList": { + "description": "DaemonSetList is a collection of daemon sets.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, "items": { - "description": "Items is the list of stateful sets.", + "description": "A list of daemon sets.", "items": { - "$ref": "#/definitions/v1.StatefulSet" + "$ref": "#/definitions/v1.DaemonSet" }, "type": "array" }, @@ -1301,7 +1990,7 @@ }, "metadata": { "$ref": "#/definitions/v1.ListMeta", - "description": "Standard list's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" } }, "required": [ @@ -1311,188 +2000,136 @@ "x-kubernetes-group-version-kind": [ { "group": "apps", - "kind": "StatefulSetList", + "kind": "DaemonSetList", "version": "v1" } ] }, - "v1.StatefulSetPersistentVolumeClaimRetentionPolicy": { - "description": "StatefulSetPersistentVolumeClaimRetentionPolicy describes the policy used for PVCs created from the StatefulSet VolumeClaimTemplates.", - "properties": { - "whenDeleted": { - "description": "WhenDeleted specifies what happens to PVCs created from StatefulSet VolumeClaimTemplates when the StatefulSet is deleted. The default policy of `Retain` causes PVCs to not be affected by StatefulSet deletion. The `Delete` policy causes those PVCs to be deleted.", - "type": "string" - }, - "whenScaled": { - "description": "WhenScaled specifies what happens to PVCs created from StatefulSet VolumeClaimTemplates when the StatefulSet is scaled down. The default policy of `Retain` causes PVCs to not be affected by a scaledown. The `Delete` policy causes the associated PVCs for any excess pods above the replica count to be deleted.", - "type": "string" - } - }, - "type": "object" - }, - "v1.StatefulSetSpec": { - "description": "A StatefulSetSpec is the specification of a StatefulSet.", + "v1.DaemonSetSpec": { + "description": "DaemonSetSpec is the specification of a daemon set.", "properties": { "minReadySeconds": { - "description": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)", - "format": "int32", - "type": "integer" - }, - "persistentVolumeClaimRetentionPolicy": { - "$ref": "#/definitions/v1.StatefulSetPersistentVolumeClaimRetentionPolicy", - "description": "persistentVolumeClaimRetentionPolicy describes the lifecycle of persistent volume claims created from volumeClaimTemplates. By default, all persistent volume claims are created as needed and retained until manually deleted. This policy allows the lifecycle to be altered, for example by deleting persistent volume claims when their stateful set is deleted, or when their pod is scaled down. This requires the StatefulSetAutoDeletePVC feature gate to be enabled, which is alpha. +optional" - }, - "podManagementPolicy": { - "description": "podManagementPolicy controls how pods are created during initial scale up, when replacing pods on nodes, or when scaling down. The default policy is `OrderedReady`, where pods are created in increasing order (pod-0, then pod-1, etc) and the controller will wait until each pod is ready before continuing. When scaling down, the pods are removed in the opposite order. The alternative policy is `Parallel` which will create pods in parallel to match the desired scale without waiting, and on scale down will delete all pods at once.\n\n", - "type": "string" - }, - "replicas": { - "description": "replicas is the desired number of replicas of the given Template. These are replicas in the sense that they are instantiations of the same Template, but individual replicas also have a consistent identity. If unspecified, defaults to 1.", + "description": "The minimum number of seconds for which a newly created DaemonSet pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready).", "format": "int32", "type": "integer" }, "revisionHistoryLimit": { - "description": "revisionHistoryLimit is the maximum number of revisions that will be maintained in the StatefulSet's revision history. The revision history consists of all revisions not represented by a currently applied StatefulSetSpec version. The default value is 10.", + "description": "The number of old history to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified. Defaults to 10.", "format": "int32", "type": "integer" }, "selector": { "$ref": "#/definitions/v1.LabelSelector", - "description": "selector is a label query over pods that should match the replica count. It must match the pod template's labels. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors" - }, - "serviceName": { - "description": "serviceName is the name of the service that governs this StatefulSet. This service must exist before the StatefulSet, and is responsible for the network identity of the set. Pods get DNS/hostnames that follow the pattern: pod-specific-string.serviceName.default.svc.cluster.local where \"pod-specific-string\" is managed by the StatefulSet controller.", - "type": "string" + "description": "A label query over pods that are managed by the daemon set. Must match in order to be controlled. It must match the pod template's labels. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors" }, "template": { "$ref": "#/definitions/v1.PodTemplateSpec", - "description": "template is the object that describes the pod that will be created if insufficient replicas are detected. Each pod stamped out by the StatefulSet will fulfill this Template, but have a unique identity from the rest of the StatefulSet." + "description": "An object that describes the pod that will be created. The DaemonSet will create exactly one copy of this pod on every node that matches the template's node selector (or on every node if no node selector is specified). The only allowed template.spec.restartPolicy value is \"Always\". More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#pod-template" }, "updateStrategy": { - "$ref": "#/definitions/v1.StatefulSetUpdateStrategy", - "description": "updateStrategy indicates the StatefulSetUpdateStrategy that will be employed to update Pods in the StatefulSet when a revision is made to Template." - }, - "volumeClaimTemplates": { - "description": "volumeClaimTemplates is a list of claims that pods are allowed to reference. The StatefulSet controller is responsible for mapping network identities to claims in a way that maintains the identity of a pod. Every claim in this list must have at least one matching (by name) volumeMount in one container in the template. A claim in this list takes precedence over any volumes in the template, with the same name.", - "items": { - "$ref": "#/definitions/v1.PersistentVolumeClaim" - }, - "type": "array" + "$ref": "#/definitions/v1.DaemonSetUpdateStrategy", + "description": "An update strategy to replace existing DaemonSet pods with new pods." } }, "required": [ "selector", - "template", - "serviceName" + "template" ], "type": "object" }, - "v1.StatefulSetStatus": { - "description": "StatefulSetStatus represents the current state of a StatefulSet.", + "v1.DaemonSetStatus": { + "description": "DaemonSetStatus represents the current status of a daemon set.", "properties": { - "availableReplicas": { - "description": "Total number of available pods (ready for at least minReadySeconds) targeted by this statefulset.", - "format": "int32", - "type": "integer" - }, "collisionCount": { - "description": "collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision.", + "description": "Count of hash collisions for the DaemonSet. The DaemonSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision.", "format": "int32", "type": "integer" }, "conditions": { - "description": "Represents the latest available observations of a statefulset's current state.", + "description": "Represents the latest available observations of a DaemonSet's current state.", "items": { - "$ref": "#/definitions/v1.StatefulSetCondition" + "$ref": "#/definitions/v1.DaemonSetCondition" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "type", "x-kubernetes-patch-strategy": "merge" }, - "currentReplicas": { - "description": "currentReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by currentRevision.", + "currentNumberScheduled": { + "description": "The number of nodes that are running at least 1 daemon pod and are supposed to run the daemon pod. More info: https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/", "format": "int32", "type": "integer" }, - "currentRevision": { - "description": "currentRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [0,currentReplicas).", - "type": "string" + "desiredNumberScheduled": { + "description": "The total number of nodes that should be running the daemon pod (including nodes correctly running the daemon pod). More info: https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/", + "format": "int32", + "type": "integer" }, - "observedGeneration": { - "description": "observedGeneration is the most recent generation observed for this StatefulSet. It corresponds to the StatefulSet's generation, which is updated on mutation by the API Server.", - "format": "int64", + "numberAvailable": { + "description": "The number of nodes that should be running the daemon pod and have one or more of the daemon pod running and available (ready for at least spec.minReadySeconds)", + "format": "int32", "type": "integer" }, - "readyReplicas": { - "description": "readyReplicas is the number of pods created for this StatefulSet with a Ready Condition.", + "numberMisscheduled": { + "description": "The number of nodes that are running the daemon pod, but are not supposed to run the daemon pod. More info: https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/", "format": "int32", "type": "integer" }, - "replicas": { - "description": "replicas is the number of Pods created by the StatefulSet controller.", + "numberReady": { + "description": "numberReady is the number of nodes that should be running the daemon pod and have one or more of the daemon pod running with a Ready Condition.", "format": "int32", "type": "integer" }, - "updateRevision": { - "description": "updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas)", - "type": "string" + "numberUnavailable": { + "description": "The number of nodes that should be running the daemon pod and have none of the daemon pod running and available (ready for at least spec.minReadySeconds)", + "format": "int32", + "type": "integer" }, - "updatedReplicas": { - "description": "updatedReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by updateRevision.", + "observedGeneration": { + "description": "The most recent generation observed by the daemon set controller.", + "format": "int64", + "type": "integer" + }, + "updatedNumberScheduled": { + "description": "The total number of nodes that are running updated daemon pod", "format": "int32", "type": "integer" } }, "required": [ - "replicas" + "currentNumberScheduled", + "numberMisscheduled", + "desiredNumberScheduled", + "numberReady" ], "type": "object" }, - "v1.StatefulSetUpdateStrategy": { - "description": "StatefulSetUpdateStrategy indicates the strategy that the StatefulSet controller will use to perform updates. It includes any additional parameters necessary to perform the update for the indicated strategy.", + "v1.DaemonSetUpdateStrategy": { + "description": "DaemonSetUpdateStrategy is a struct used to control the update strategy for a DaemonSet.", "properties": { "rollingUpdate": { - "$ref": "#/definitions/v1.RollingUpdateStatefulSetStrategy", - "description": "RollingUpdate is used to communicate parameters when Type is RollingUpdateStatefulSetStrategyType." + "$ref": "#/definitions/v1.RollingUpdateDaemonSet", + "description": "Rolling update config params. Present only if type = \"RollingUpdate\"." }, "type": { - "description": "Type indicates the type of the StatefulSetUpdateStrategy. Default is RollingUpdate.\n\n", + "description": "Type of daemon set update. Can be \"RollingUpdate\" or \"OnDelete\". Default is RollingUpdate.", "type": "string" } }, "type": "object" }, - "v1.BoundObjectReference": { - "description": "BoundObjectReference is a reference to an object that a token is bound to.", + "v1.Deployment": { + "description": "Deployment enables declarative updates for Pods and ReplicaSets.", "properties": { "apiVersion": { - "description": "API version of the referent.", + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, "kind": { - "description": "Kind of the referent. Valid kinds are 'Pod' and 'Secret'.", - "type": "string" - }, - "name": { - "description": "Name of the referent.", - "type": "string" - }, - "uid": { - "description": "UID of the referent.", - "type": "string" - } - }, - "type": "object" - }, - "authentication.v1.TokenRequest": { - "description": "TokenRequest requests a token for a given service account.", - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", "type": "string" }, "metadata": { @@ -1500,181 +2137,216 @@ "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" }, "spec": { - "$ref": "#/definitions/v1.TokenRequestSpec", - "description": "Spec holds information about the request being evaluated" + "$ref": "#/definitions/v1.DeploymentSpec", + "description": "Specification of the desired behavior of the Deployment." }, "status": { - "$ref": "#/definitions/v1.TokenRequestStatus", - "description": "Status is filled in by the server and indicates whether the token can be authenticated." + "$ref": "#/definitions/v1.DeploymentStatus", + "description": "Most recently observed status of the Deployment." } }, - "required": [ - "spec" - ], "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "authentication.k8s.io", - "kind": "TokenRequest", + "group": "apps", + "kind": "Deployment", "version": "v1" } ] }, - "v1.TokenRequestSpec": { - "description": "TokenRequestSpec contains client provided parameters of a token request.", + "v1.DeploymentCondition": { + "description": "DeploymentCondition describes the state of a deployment at a certain point.", "properties": { - "audiences": { - "description": "Audiences are the intendend audiences of the token. A recipient of a token must identify themself with an identifier in the list of audiences of the token, and otherwise should reject the token. A token issued for multiple audiences may be used to authenticate against any of the audiences listed but implies a high degree of trust between the target audiences.", - "items": { - "type": "string" - }, - "type": "array" - }, - "boundObjectRef": { - "$ref": "#/definitions/v1.BoundObjectReference", - "description": "BoundObjectRef is a reference to an object that the token will be bound to. The token will only be valid for as long as the bound object exists. NOTE: The API server's TokenReview endpoint will validate the BoundObjectRef, but other audiences may not. Keep ExpirationSeconds small if you want prompt revocation." + "lastTransitionTime": { + "description": "Last time the condition transitioned from one status to another.", + "format": "date-time", + "type": "string" }, - "expirationSeconds": { - "description": "ExpirationSeconds is the requested duration of validity of the request. The token issuer may return a token with a different validity duration so a client needs to check the 'expiration' field in a response.", - "format": "int64", - "type": "integer" - } - }, - "required": [ - "audiences" - ], - "type": "object" - }, - "v1.TokenRequestStatus": { - "description": "TokenRequestStatus is the result of a token request.", - "properties": { - "expirationTimestamp": { - "description": "ExpirationTimestamp is the time of expiration of the returned token.", + "lastUpdateTime": { + "description": "The last time this condition was updated.", "format": "date-time", "type": "string" }, - "token": { - "description": "Token is the opaque bearer token.", + "message": { + "description": "A human readable message indicating details about the transition.", + "type": "string" + }, + "reason": { + "description": "The reason for the condition's last transition.", + "type": "string" + }, + "status": { + "description": "Status of the condition, one of True, False, Unknown.", + "type": "string" + }, + "type": { + "description": "Type of deployment condition.", "type": "string" } }, "required": [ - "token", - "expirationTimestamp" + "type", + "status" ], "type": "object" }, - "v1.TokenReview": { - "description": "TokenReview attempts to authenticate a token to a known user. Note: TokenReview requests may be cached by the webhook token authenticator plugin in the kube-apiserver.", + "v1.DeploymentList": { + "description": "DeploymentList is a list of Deployments.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, + "items": { + "description": "Items is the list of Deployments.", + "items": { + "$ref": "#/definitions/v1.Deployment" + }, + "type": "array" + }, "kind": { "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", "type": "string" }, "metadata": { - "$ref": "#/definitions/v1.ObjectMeta", - "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" - }, - "spec": { - "$ref": "#/definitions/v1.TokenReviewSpec", - "description": "Spec holds information about the request being evaluated" - }, - "status": { - "$ref": "#/definitions/v1.TokenReviewStatus", - "description": "Status is filled in by the server and indicates whether the request can be authenticated." + "$ref": "#/definitions/v1.ListMeta", + "description": "Standard list metadata." } }, "required": [ - "spec" + "items" ], "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "authentication.k8s.io", - "kind": "TokenReview", + "group": "apps", + "kind": "DeploymentList", "version": "v1" } ] }, - "v1.TokenReviewSpec": { - "description": "TokenReviewSpec is a description of the token authentication request.", + "v1.DeploymentSpec": { + "description": "DeploymentSpec is the specification of the desired behavior of the Deployment.", "properties": { - "audiences": { - "description": "Audiences is a list of the identifiers that the resource server presented with the token identifies as. Audience-aware token authenticators will verify that the token was intended for at least one of the audiences in this list. If no audiences are provided, the audience will default to the audience of the Kubernetes apiserver.", - "items": { - "type": "string" - }, - "type": "array" + "minReadySeconds": { + "description": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)", + "format": "int32", + "type": "integer" }, - "token": { - "description": "Token is the opaque bearer token.", - "type": "string" + "paused": { + "description": "Indicates that the deployment is paused.", + "type": "boolean" + }, + "progressDeadlineSeconds": { + "description": "The maximum time in seconds for a deployment to make progress before it is considered to be failed. The deployment controller will continue to process failed deployments and a condition with a ProgressDeadlineExceeded reason will be surfaced in the deployment status. Note that progress will not be estimated during the time a deployment is paused. Defaults to 600s.", + "format": "int32", + "type": "integer" + }, + "replicas": { + "description": "Number of desired pods. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1.", + "format": "int32", + "type": "integer" + }, + "revisionHistoryLimit": { + "description": "The number of old ReplicaSets to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified. Defaults to 10.", + "format": "int32", + "type": "integer" + }, + "selector": { + "$ref": "#/definitions/v1.LabelSelector", + "description": "Label selector for pods. Existing ReplicaSets whose pods are selected by this will be the ones affected by this deployment. It must match the pod template's labels." + }, + "strategy": { + "$ref": "#/definitions/v1.DeploymentStrategy", + "description": "The deployment strategy to use to replace existing pods with new ones.", + "x-kubernetes-patch-strategy": "retainKeys" + }, + "template": { + "$ref": "#/definitions/v1.PodTemplateSpec", + "description": "Template describes the pods that will be created. The only allowed template.spec.restartPolicy value is \"Always\"." } }, + "required": [ + "selector", + "template" + ], "type": "object" }, - "v1.TokenReviewStatus": { - "description": "TokenReviewStatus is the result of the token authentication request.", + "v1.DeploymentStatus": { + "description": "DeploymentStatus is the most recently observed status of the Deployment.", "properties": { - "audiences": { - "description": "Audiences are audience identifiers chosen by the authenticator that are compatible with both the TokenReview and token. An identifier is any identifier in the intersection of the TokenReviewSpec audiences and the token's audiences. A client of the TokenReview API that sets the spec.audiences field should validate that a compatible audience identifier is returned in the status.audiences field to ensure that the TokenReview server is audience aware. If a TokenReview returns an empty status.audience field where status.authenticated is \"true\", the token is valid against the audience of the Kubernetes API server.", + "availableReplicas": { + "description": "Total number of available non-terminating pods (ready for at least minReadySeconds) targeted by this deployment.", + "format": "int32", + "type": "integer" + }, + "collisionCount": { + "description": "Count of hash collisions for the Deployment. The Deployment controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ReplicaSet.", + "format": "int32", + "type": "integer" + }, + "conditions": { + "description": "Represents the latest available observations of a deployment's current state.", "items": { - "type": "string" + "$ref": "#/definitions/v1.DeploymentCondition" }, - "type": "array" + "type": "array", + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" }, - "authenticated": { - "description": "Authenticated indicates that the token was associated with a known user.", - "type": "boolean" + "observedGeneration": { + "description": "The generation observed by the deployment controller.", + "format": "int64", + "type": "integer" }, - "error": { - "description": "Error indicates that the token couldn't be checked", - "type": "string" + "readyReplicas": { + "description": "Total number of non-terminating pods targeted by this Deployment with a Ready Condition.", + "format": "int32", + "type": "integer" }, - "user": { - "$ref": "#/definitions/v1.UserInfo", - "description": "User is the UserInfo associated with the provided token." + "replicas": { + "description": "Total number of non-terminating pods targeted by this deployment (their labels match the selector).", + "format": "int32", + "type": "integer" + }, + "terminatingReplicas": { + "description": "Total number of terminating pods targeted by this deployment. Terminating pods have a non-null .metadata.deletionTimestamp and have not yet reached the Failed or Succeeded .status.phase.\n\nThis is an alpha field. Enable DeploymentReplicaSetTerminatingReplicas to be able to use this field.", + "format": "int32", + "type": "integer" + }, + "unavailableReplicas": { + "description": "Total number of unavailable pods targeted by this deployment. This is the total number of pods that are still required for the deployment to have 100% available capacity. They may either be pods that are running but not yet available or pods that still have not been created.", + "format": "int32", + "type": "integer" + }, + "updatedReplicas": { + "description": "Total number of non-terminating pods targeted by this deployment that have the desired template spec.", + "format": "int32", + "type": "integer" } }, "type": "object" }, - "v1.UserInfo": { - "description": "UserInfo holds the information about the user needed to implement the user.Info interface.", + "v1.DeploymentStrategy": { + "description": "DeploymentStrategy describes how to replace existing pods with new ones.", "properties": { - "extra": { - "additionalProperties": { - "items": { - "type": "string" - }, - "type": "array" - }, - "description": "Any additional information provided by the authenticator.", - "type": "object" - }, - "groups": { - "description": "The names of groups this user is a part of.", - "items": { - "type": "string" - }, - "type": "array" - }, - "uid": { - "description": "A unique value that identifies this user across time. If this user is deleted and another user by the same name is added, they will have different UIDs.", - "type": "string" + "rollingUpdate": { + "$ref": "#/definitions/v1.RollingUpdateDeployment", + "description": "Rolling update config params. Present only if DeploymentStrategyType = RollingUpdate." }, - "username": { - "description": "The name that uniquely identifies this user among all active users.", + "type": { + "description": "Type of deployment. Can be \"Recreate\" or \"RollingUpdate\". Default is RollingUpdate.", "type": "string" } }, "type": "object" }, - "v1.LocalSubjectAccessReview": { - "description": "LocalSubjectAccessReview checks whether or not a user or group can perform an action in a given namespace. Having a namespace scoped resource makes it much easier to grant namespace scoped policy that includes permissions checking.", + "v1.ReplicaSet": { + "description": "ReplicaSet ensures that a specified number of pod replicas are running at any given time.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", @@ -1686,139 +2358,216 @@ }, "metadata": { "$ref": "#/definitions/v1.ObjectMeta", - "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + "description": "If the Labels of a ReplicaSet are empty, they are defaulted to be the same as the Pod(s) that the ReplicaSet manages. Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" }, "spec": { - "$ref": "#/definitions/v1.SubjectAccessReviewSpec", - "description": "Spec holds information about the request being evaluated. spec.namespace must be equal to the namespace you made the request against. If empty, it is defaulted." + "$ref": "#/definitions/v1.ReplicaSetSpec", + "description": "Spec defines the specification of the desired behavior of the ReplicaSet. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" }, "status": { - "$ref": "#/definitions/v1.SubjectAccessReviewStatus", - "description": "Status is filled in by the server and indicates whether the request is allowed or not" + "$ref": "#/definitions/v1.ReplicaSetStatus", + "description": "Status is the most recently observed status of the ReplicaSet. This data may be out of date by some window of time. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, - "required": [ - "spec" - ], "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "authorization.k8s.io", - "kind": "LocalSubjectAccessReview", + "group": "apps", + "kind": "ReplicaSet", "version": "v1" } ] }, - "v1.NonResourceAttributes": { - "description": "NonResourceAttributes includes the authorization attributes available for non-resource requests to the Authorizer interface", + "v1.ReplicaSetCondition": { + "description": "ReplicaSetCondition describes the state of a replica set at a certain point.", "properties": { - "path": { - "description": "Path is the URL path of the request", + "lastTransitionTime": { + "description": "The last time the condition transitioned from one status to another.", + "format": "date-time", "type": "string" }, - "verb": { - "description": "Verb is the standard HTTP verb", + "message": { + "description": "A human readable message indicating details about the transition.", + "type": "string" + }, + "reason": { + "description": "The reason for the condition's last transition.", + "type": "string" + }, + "status": { + "description": "Status of the condition, one of True, False, Unknown.", + "type": "string" + }, + "type": { + "description": "Type of replica set condition.", "type": "string" } }, + "required": [ + "type", + "status" + ], "type": "object" }, - "v1.NonResourceRule": { - "description": "NonResourceRule holds information that describes a rule for the non-resource", + "v1.ReplicaSetList": { + "description": "ReplicaSetList is a collection of ReplicaSets.", "properties": { - "nonResourceURLs": { - "description": "NonResourceURLs is a set of partial urls that a user should have access to. *s are allowed, but only as the full, final step in the path. \"*\" means all.", - "items": { - "type": "string" - }, - "type": "array" + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" }, - "verbs": { - "description": "Verb is a list of kubernetes non-resource API verbs, like: get, post, put, delete, patch, head, options. \"*\" means all.", + "items": { + "description": "List of ReplicaSets. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset", "items": { - "type": "string" + "$ref": "#/definitions/v1.ReplicaSet" }, "type": "array" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/v1.ListMeta", + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds" } }, "required": [ - "verbs" + "items" ], - "type": "object" + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "apps", + "kind": "ReplicaSetList", + "version": "v1" + } + ] }, - "v1.ResourceAttributes": { - "description": "ResourceAttributes includes the authorization attributes available for resource requests to the Authorizer interface", + "v1.ReplicaSetSpec": { + "description": "ReplicaSetSpec is the specification of a ReplicaSet.", "properties": { - "group": { - "description": "Group is the API Group of the Resource. \"*\" means all.", - "type": "string" - }, - "name": { - "description": "Name is the name of the resource being requested for a \"get\" or deleted for a \"delete\". \"\" (empty) means all.", - "type": "string" - }, - "namespace": { - "description": "Namespace is the namespace of the action being requested. Currently, there is no distinction between no namespace and all namespaces \"\" (empty) is defaulted for LocalSubjectAccessReviews \"\" (empty) is empty for cluster-scoped resources \"\" (empty) means \"all\" for namespace scoped resources from a SubjectAccessReview or SelfSubjectAccessReview", - "type": "string" - }, - "resource": { - "description": "Resource is one of the existing resource types. \"*\" means all.", - "type": "string" + "minReadySeconds": { + "description": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)", + "format": "int32", + "type": "integer" }, - "subresource": { - "description": "Subresource is one of the existing resource types. \"\" means none.", - "type": "string" + "replicas": { + "description": "Replicas is the number of desired pods. This is a pointer to distinguish between explicit zero and unspecified. Defaults to 1. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset", + "format": "int32", + "type": "integer" }, - "verb": { - "description": "Verb is a kubernetes resource API verb, like: get, list, watch, create, update, delete, proxy. \"*\" means all.", - "type": "string" + "selector": { + "$ref": "#/definitions/v1.LabelSelector", + "description": "Selector is a label query over pods that should match the replica count. Label keys and values that must match in order to be controlled by this replica set. It must match the pod template's labels. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors" }, - "version": { - "description": "Version is the API Version of the Resource. \"*\" means all.", - "type": "string" + "template": { + "$ref": "#/definitions/v1.PodTemplateSpec", + "description": "Template is the object that describes the pod that will be created if insufficient replicas are detected. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/#pod-template" } }, + "required": [ + "selector" + ], "type": "object" }, - "v1.ResourceRule": { - "description": "ResourceRule is the list of actions the subject is allowed to perform on resources. The list ordering isn't significant, may contain duplicates, and possibly be incomplete.", + "v1.ReplicaSetStatus": { + "description": "ReplicaSetStatus represents the current status of a ReplicaSet.", "properties": { - "apiGroups": { - "description": "APIGroups is the name of the APIGroup that contains the resources. If multiple API groups are specified, any action requested against one of the enumerated resources in any API group will be allowed. \"*\" means all.", - "items": { - "type": "string" - }, - "type": "array" + "availableReplicas": { + "description": "The number of available non-terminating pods (ready for at least minReadySeconds) for this replica set.", + "format": "int32", + "type": "integer" }, - "resourceNames": { - "description": "ResourceNames is an optional white list of names that the rule applies to. An empty set means that everything is allowed. \"*\" means all.", + "conditions": { + "description": "Represents the latest available observations of a replica set's current state.", "items": { - "type": "string" + "$ref": "#/definitions/v1.ReplicaSetCondition" }, - "type": "array" + "type": "array", + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" }, - "resources": { - "description": "Resources is a list of resources this rule applies to. \"*\" means all in the specified apiGroups.\n \"*/foo\" represents the subresource 'foo' for all resources in the specified apiGroups.", - "items": { - "type": "string" - }, - "type": "array" + "fullyLabeledReplicas": { + "description": "The number of non-terminating pods that have labels matching the labels of the pod template of the replicaset.", + "format": "int32", + "type": "integer" }, - "verbs": { - "description": "Verb is a list of kubernetes resource API verbs, like: get, list, watch, create, update, delete, proxy. \"*\" means all.", - "items": { - "type": "string" - }, - "type": "array" + "observedGeneration": { + "description": "ObservedGeneration reflects the generation of the most recently observed ReplicaSet.", + "format": "int64", + "type": "integer" + }, + "readyReplicas": { + "description": "The number of non-terminating pods targeted by this ReplicaSet with a Ready Condition.", + "format": "int32", + "type": "integer" + }, + "replicas": { + "description": "Replicas is the most recently observed number of non-terminating pods. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset", + "format": "int32", + "type": "integer" + }, + "terminatingReplicas": { + "description": "The number of terminating pods for this replica set. Terminating pods have a non-null .metadata.deletionTimestamp and have not yet reached the Failed or Succeeded .status.phase.\n\nThis is an alpha field. Enable DeploymentReplicaSetTerminatingReplicas to be able to use this field.", + "format": "int32", + "type": "integer" } }, "required": [ - "verbs" + "replicas" ], "type": "object" }, - "v1.SelfSubjectAccessReview": { - "description": "SelfSubjectAccessReview checks whether or the current user can perform an action. Not filling in a spec.namespace means \"in all namespaces\". Self is a special case, because users should always be able to check whether they can perform an action", + "v1.RollingUpdateDaemonSet": { + "description": "Spec to control the desired behavior of daemon set rolling update.", + "properties": { + "maxSurge": { + "$ref": "#/definitions/intstr.IntOrString", + "description": "The maximum number of nodes with an existing available DaemonSet pod that can have an updated DaemonSet pod during during an update. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). This can not be 0 if MaxUnavailable is 0. Absolute number is calculated from percentage by rounding up to a minimum of 1. Default value is 0. Example: when this is set to 30%, at most 30% of the total number of nodes that should be running the daemon pod (i.e. status.desiredNumberScheduled) can have their a new pod created before the old pod is marked as deleted. The update starts by launching new pods on 30% of nodes. Once an updated pod is available (Ready for at least minReadySeconds) the old DaemonSet pod on that node is marked deleted. If the old pod becomes unavailable for any reason (Ready transitions to false, is evicted, or is drained) an updated pod is immediately created on that node without considering surge limits. Allowing surge implies the possibility that the resources consumed by the daemonset on any given node can double if the readiness check fails, and so resource intensive daemonsets should take into account that they may cause evictions during disruption." + }, + "maxUnavailable": { + "$ref": "#/definitions/intstr.IntOrString", + "description": "The maximum number of DaemonSet pods that can be unavailable during the update. Value can be an absolute number (ex: 5) or a percentage of total number of DaemonSet pods at the start of the update (ex: 10%). Absolute number is calculated from percentage by rounding up. This cannot be 0 if MaxSurge is 0 Default value is 1. Example: when this is set to 30%, at most 30% of the total number of nodes that should be running the daemon pod (i.e. status.desiredNumberScheduled) can have their pods stopped for an update at any given time. The update starts by stopping at most 30% of those DaemonSet pods and then brings up new DaemonSet pods in their place. Once the new pods are available, it then proceeds onto other DaemonSet pods, thus ensuring that at least 70% of original number of DaemonSet pods are available at all times during the update." + } + }, + "type": "object" + }, + "v1.RollingUpdateDeployment": { + "description": "Spec to control the desired behavior of rolling update.", + "properties": { + "maxSurge": { + "$ref": "#/definitions/intstr.IntOrString", + "description": "The maximum number of pods that can be scheduled above the desired number of pods. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). This can not be 0 if MaxUnavailable is 0. Absolute number is calculated from percentage by rounding up. Defaults to 25%. Example: when this is set to 30%, the new ReplicaSet can be scaled up immediately when the rolling update starts, such that the total number of old and new pods do not exceed 130% of desired pods. Once old pods have been killed, new ReplicaSet can be scaled up further, ensuring that total number of pods running at any time during the update is at most 130% of desired pods." + }, + "maxUnavailable": { + "$ref": "#/definitions/intstr.IntOrString", + "description": "The maximum number of pods that can be unavailable during the update. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). Absolute number is calculated from percentage by rounding down. This can not be 0 if MaxSurge is 0. Defaults to 25%. Example: when this is set to 30%, the old ReplicaSet can be scaled down to 70% of desired pods immediately when the rolling update starts. Once new pods are ready, old ReplicaSet can be scaled down further, followed by scaling up the new ReplicaSet, ensuring that the total number of pods available at all times during the update is at least 70% of desired pods." + } + }, + "type": "object" + }, + "v1.RollingUpdateStatefulSetStrategy": { + "description": "RollingUpdateStatefulSetStrategy is used to communicate parameter for RollingUpdateStatefulSetStrategyType.", + "properties": { + "maxUnavailable": { + "$ref": "#/definitions/intstr.IntOrString", + "description": "The maximum number of pods that can be unavailable during the update. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). Absolute number is calculated from percentage by rounding up. This can not be 0. Defaults to 1. This field is alpha-level and is only honored by servers that enable the MaxUnavailableStatefulSet feature. The field applies to all pods in the range 0 to Replicas-1. That means if there is any unavailable pod in the range 0 to Replicas-1, it will be counted towards MaxUnavailable." + }, + "partition": { + "description": "Partition indicates the ordinal at which the StatefulSet should be partitioned for updates. During a rolling update, all pods from ordinal Replicas-1 to Partition are updated. All pods from ordinal Partition-1 to 0 remain untouched. This is helpful in being able to do a canary based deployment. The default value is 0.", + "format": "int32", + "type": "integer" + } + }, + "type": "object" + }, + "v1.StatefulSet": { + "description": "StatefulSet represents a set of pods with consistent identities. Identities are defined as:\n - Network: A single stable DNS and hostname.\n - Storage: As many VolumeClaims as requested.\n\nThe StatefulSet guarantees that a given network identity will always map to the same storage identity.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", @@ -1830,247 +2579,281 @@ }, "metadata": { "$ref": "#/definitions/v1.ObjectMeta", - "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" }, "spec": { - "$ref": "#/definitions/v1.SelfSubjectAccessReviewSpec", - "description": "Spec holds information about the request being evaluated. user and groups must be empty" + "$ref": "#/definitions/v1.StatefulSetSpec", + "description": "Spec defines the desired identities of pods in this set." }, "status": { - "$ref": "#/definitions/v1.SubjectAccessReviewStatus", - "description": "Status is filled in by the server and indicates whether the request is allowed or not" + "$ref": "#/definitions/v1.StatefulSetStatus", + "description": "Status is the current status of Pods in this StatefulSet. This data may be out of date by some window of time." } }, - "required": [ - "spec" - ], "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "authorization.k8s.io", - "kind": "SelfSubjectAccessReview", + "group": "apps", + "kind": "StatefulSet", "version": "v1" } ] }, - "v1.SelfSubjectAccessReviewSpec": { - "description": "SelfSubjectAccessReviewSpec is a description of the access request. Exactly one of ResourceAuthorizationAttributes and NonResourceAuthorizationAttributes must be set", + "v1.StatefulSetCondition": { + "description": "StatefulSetCondition describes the state of a statefulset at a certain point.", "properties": { - "nonResourceAttributes": { - "$ref": "#/definitions/v1.NonResourceAttributes", - "description": "NonResourceAttributes describes information for a non-resource access request" + "lastTransitionTime": { + "description": "Last time the condition transitioned from one status to another.", + "format": "date-time", + "type": "string" }, - "resourceAttributes": { - "$ref": "#/definitions/v1.ResourceAttributes", - "description": "ResourceAuthorizationAttributes describes information for a resource access request" + "message": { + "description": "A human readable message indicating details about the transition.", + "type": "string" + }, + "reason": { + "description": "The reason for the condition's last transition.", + "type": "string" + }, + "status": { + "description": "Status of the condition, one of True, False, Unknown.", + "type": "string" + }, + "type": { + "description": "Type of statefulset condition.", + "type": "string" } }, + "required": [ + "type", + "status" + ], "type": "object" }, - "v1.SelfSubjectRulesReview": { - "description": "SelfSubjectRulesReview enumerates the set of actions the current user can perform within a namespace. The returned list of actions may be incomplete depending on the server's authorization mode, and any errors experienced during the evaluation. SelfSubjectRulesReview should be used by UIs to show/hide actions, or to quickly let an end user reason about their permissions. It should NOT Be used by external systems to drive authorization decisions as this raises confused deputy, cache lifetime/revocation, and correctness concerns. SubjectAccessReview, and LocalAccessReview are the correct way to defer authorization decisions to the API server.", + "v1.StatefulSetList": { + "description": "StatefulSetList is a collection of StatefulSets.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, + "items": { + "description": "Items is the list of stateful sets.", + "items": { + "$ref": "#/definitions/v1.StatefulSet" + }, + "type": "array" + }, "kind": { "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", "type": "string" }, "metadata": { - "$ref": "#/definitions/v1.ObjectMeta", - "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" - }, - "spec": { - "$ref": "#/definitions/v1.SelfSubjectRulesReviewSpec", - "description": "Spec holds information about the request being evaluated." - }, - "status": { - "$ref": "#/definitions/v1.SubjectRulesReviewStatus", - "description": "Status is filled in by the server and indicates the set of actions a user can perform." + "$ref": "#/definitions/v1.ListMeta", + "description": "Standard list's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" } }, "required": [ - "spec" + "items" ], "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "authorization.k8s.io", - "kind": "SelfSubjectRulesReview", + "group": "apps", + "kind": "StatefulSetList", "version": "v1" } ] }, - "v1.SelfSubjectRulesReviewSpec": { - "description": "SelfSubjectRulesReviewSpec defines the specification for SelfSubjectRulesReview.", + "v1.StatefulSetOrdinals": { + "description": "StatefulSetOrdinals describes the policy used for replica ordinal assignment in this StatefulSet.", "properties": { - "namespace": { - "description": "Namespace to evaluate rules for. Required.", + "start": { + "description": "start is the number representing the first replica's index. It may be used to number replicas from an alternate index (eg: 1-indexed) over the default 0-indexed names, or to orchestrate progressive movement of replicas from one StatefulSet to another. If set, replica indices will be in the range:\n [.spec.ordinals.start, .spec.ordinals.start + .spec.replicas).\nIf unset, defaults to 0. Replica indices will be in the range:\n [0, .spec.replicas).", + "format": "int32", + "type": "integer" + } + }, + "type": "object" + }, + "v1.StatefulSetPersistentVolumeClaimRetentionPolicy": { + "description": "StatefulSetPersistentVolumeClaimRetentionPolicy describes the policy used for PVCs created from the StatefulSet VolumeClaimTemplates.", + "properties": { + "whenDeleted": { + "description": "WhenDeleted specifies what happens to PVCs created from StatefulSet VolumeClaimTemplates when the StatefulSet is deleted. The default policy of `Retain` causes PVCs to not be affected by StatefulSet deletion. The `Delete` policy causes those PVCs to be deleted.", + "type": "string" + }, + "whenScaled": { + "description": "WhenScaled specifies what happens to PVCs created from StatefulSet VolumeClaimTemplates when the StatefulSet is scaled down. The default policy of `Retain` causes PVCs to not be affected by a scaledown. The `Delete` policy causes the associated PVCs for any excess pods above the replica count to be deleted.", "type": "string" } }, "type": "object" }, - "v1.SubjectAccessReview": { - "description": "SubjectAccessReview checks whether or not a user or group can perform an action.", + "v1.StatefulSetSpec": { + "description": "A StatefulSetSpec is the specification of a StatefulSet.", "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "minReadySeconds": { + "description": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)", + "format": "int32", + "type": "integer" + }, + "ordinals": { + "$ref": "#/definitions/v1.StatefulSetOrdinals", + "description": "ordinals controls the numbering of replica indices in a StatefulSet. The default ordinals behavior assigns a \"0\" index to the first replica and increments the index by one for each additional replica requested." + }, + "persistentVolumeClaimRetentionPolicy": { + "$ref": "#/definitions/v1.StatefulSetPersistentVolumeClaimRetentionPolicy", + "description": "persistentVolumeClaimRetentionPolicy describes the lifecycle of persistent volume claims created from volumeClaimTemplates. By default, all persistent volume claims are created as needed and retained until manually deleted. This policy allows the lifecycle to be altered, for example by deleting persistent volume claims when their stateful set is deleted, or when their pod is scaled down." + }, + "podManagementPolicy": { + "description": "podManagementPolicy controls how pods are created during initial scale up, when replacing pods on nodes, or when scaling down. The default policy is `OrderedReady`, where pods are created in increasing order (pod-0, then pod-1, etc) and the controller will wait until each pod is ready before continuing. When scaling down, the pods are removed in the opposite order. The alternative policy is `Parallel` which will create pods in parallel to match the desired scale without waiting, and on scale down will delete all pods at once.", "type": "string" }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "replicas": { + "description": "replicas is the desired number of replicas of the given Template. These are replicas in the sense that they are instantiations of the same Template, but individual replicas also have a consistent identity. If unspecified, defaults to 1.", + "format": "int32", + "type": "integer" + }, + "revisionHistoryLimit": { + "description": "revisionHistoryLimit is the maximum number of revisions that will be maintained in the StatefulSet's revision history. The revision history consists of all revisions not represented by a currently applied StatefulSetSpec version. The default value is 10.", + "format": "int32", + "type": "integer" + }, + "selector": { + "$ref": "#/definitions/v1.LabelSelector", + "description": "selector is a label query over pods that should match the replica count. It must match the pod template's labels. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors" + }, + "serviceName": { + "description": "serviceName is the name of the service that governs this StatefulSet. This service must exist before the StatefulSet, and is responsible for the network identity of the set. Pods get DNS/hostnames that follow the pattern: pod-specific-string.serviceName.default.svc.cluster.local where \"pod-specific-string\" is managed by the StatefulSet controller.", "type": "string" }, - "metadata": { - "$ref": "#/definitions/v1.ObjectMeta", - "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + "template": { + "$ref": "#/definitions/v1.PodTemplateSpec", + "description": "template is the object that describes the pod that will be created if insufficient replicas are detected. Each pod stamped out by the StatefulSet will fulfill this Template, but have a unique identity from the rest of the StatefulSet. Each pod will be named with the format -. For example, a pod in a StatefulSet named \"web\" with index number \"3\" would be named \"web-3\". The only allowed template.spec.restartPolicy value is \"Always\"." }, - "spec": { - "$ref": "#/definitions/v1.SubjectAccessReviewSpec", - "description": "Spec holds information about the request being evaluated" + "updateStrategy": { + "$ref": "#/definitions/v1.StatefulSetUpdateStrategy", + "description": "updateStrategy indicates the StatefulSetUpdateStrategy that will be employed to update Pods in the StatefulSet when a revision is made to Template." }, - "status": { - "$ref": "#/definitions/v1.SubjectAccessReviewStatus", - "description": "Status is filled in by the server and indicates whether the request is allowed or not" + "volumeClaimTemplates": { + "description": "volumeClaimTemplates is a list of claims that pods are allowed to reference. The StatefulSet controller is responsible for mapping network identities to claims in a way that maintains the identity of a pod. Every claim in this list must have at least one matching (by name) volumeMount in one container in the template. A claim in this list takes precedence over any volumes in the template, with the same name.", + "items": { + "$ref": "#/definitions/v1.PersistentVolumeClaim" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "required": [ - "spec" + "selector", + "template" ], - "type": "object", - "x-kubernetes-group-version-kind": [ - { - "group": "authorization.k8s.io", - "kind": "SubjectAccessReview", - "version": "v1" - } - ] + "type": "object" }, - "v1.SubjectAccessReviewSpec": { - "description": "SubjectAccessReviewSpec is a description of the access request. Exactly one of ResourceAuthorizationAttributes and NonResourceAuthorizationAttributes must be set", + "v1.StatefulSetStatus": { + "description": "StatefulSetStatus represents the current state of a StatefulSet.", "properties": { - "extra": { - "additionalProperties": { - "items": { - "type": "string" - }, - "type": "array" - }, - "description": "Extra corresponds to the user.Info.GetExtra() method from the authenticator. Since that is input to the authorizer it needs a reflection here.", - "type": "object" + "availableReplicas": { + "description": "Total number of available pods (ready for at least minReadySeconds) targeted by this statefulset.", + "format": "int32", + "type": "integer" }, - "groups": { - "description": "Groups is the groups you're testing for.", + "collisionCount": { + "description": "collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision.", + "format": "int32", + "type": "integer" + }, + "conditions": { + "description": "Represents the latest available observations of a statefulset's current state.", "items": { - "type": "string" + "$ref": "#/definitions/v1.StatefulSetCondition" }, - "type": "array" - }, - "nonResourceAttributes": { - "$ref": "#/definitions/v1.NonResourceAttributes", - "description": "NonResourceAttributes describes information for a non-resource access request" + "type": "array", + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" }, - "resourceAttributes": { - "$ref": "#/definitions/v1.ResourceAttributes", - "description": "ResourceAuthorizationAttributes describes information for a resource access request" + "currentReplicas": { + "description": "currentReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by currentRevision.", + "format": "int32", + "type": "integer" }, - "uid": { - "description": "UID information about the requesting user.", + "currentRevision": { + "description": "currentRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [0,currentReplicas).", "type": "string" }, - "user": { - "description": "User is the user you're testing for. If you specify \"User\" but not \"Groups\", then is it interpreted as \"What if User were not a member of any groups", - "type": "string" - } - }, - "type": "object" - }, - "v1.SubjectAccessReviewStatus": { - "description": "SubjectAccessReviewStatus", - "properties": { - "allowed": { - "description": "Allowed is required. True if the action would be allowed, false otherwise.", - "type": "boolean" + "observedGeneration": { + "description": "observedGeneration is the most recent generation observed for this StatefulSet. It corresponds to the StatefulSet's generation, which is updated on mutation by the API Server.", + "format": "int64", + "type": "integer" }, - "denied": { - "description": "Denied is optional. True if the action would be denied, otherwise false. If both allowed is false and denied is false, then the authorizer has no opinion on whether to authorize the action. Denied may not be true if Allowed is true.", - "type": "boolean" + "readyReplicas": { + "description": "readyReplicas is the number of pods created for this StatefulSet with a Ready Condition.", + "format": "int32", + "type": "integer" }, - "evaluationError": { - "description": "EvaluationError is an indication that some error occurred during the authorization check. It is entirely possible to get an error and be able to continue determine authorization status in spite of it. For instance, RBAC can be missing a role, but enough roles are still present and bound to reason about the request.", - "type": "string" + "replicas": { + "description": "replicas is the number of Pods created by the StatefulSet controller.", + "format": "int32", + "type": "integer" }, - "reason": { - "description": "Reason is optional. It indicates why a request was allowed or denied.", + "updateRevision": { + "description": "updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas)", "type": "string" + }, + "updatedReplicas": { + "description": "updatedReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by updateRevision.", + "format": "int32", + "type": "integer" } }, "required": [ - "allowed" + "replicas" ], "type": "object" }, - "v1.SubjectRulesReviewStatus": { - "description": "SubjectRulesReviewStatus contains the result of a rules check. This check can be incomplete depending on the set of authorizers the server is configured with and any errors experienced during evaluation. Because authorization rules are additive, if a rule appears in a list it's safe to assume the subject has that permission, even if that list is incomplete.", + "v1.StatefulSetUpdateStrategy": { + "description": "StatefulSetUpdateStrategy indicates the strategy that the StatefulSet controller will use to perform updates. It includes any additional parameters necessary to perform the update for the indicated strategy.", "properties": { - "evaluationError": { - "description": "EvaluationError can appear in combination with Rules. It indicates an error occurred during rule evaluation, such as an authorizer that doesn't support rule evaluation, and that ResourceRules and/or NonResourceRules may be incomplete.", - "type": "string" - }, - "incomplete": { - "description": "Incomplete is true when the rules returned by this call are incomplete. This is most commonly encountered when an authorizer, such as an external authorizer, doesn't support rules evaluation.", - "type": "boolean" - }, - "nonResourceRules": { - "description": "NonResourceRules is the list of actions the subject is allowed to perform on non-resources. The list ordering isn't significant, may contain duplicates, and possibly be incomplete.", - "items": { - "$ref": "#/definitions/v1.NonResourceRule" - }, - "type": "array" + "rollingUpdate": { + "$ref": "#/definitions/v1.RollingUpdateStatefulSetStrategy", + "description": "RollingUpdate is used to communicate parameters when Type is RollingUpdateStatefulSetStrategyType." }, - "resourceRules": { - "description": "ResourceRules is the list of actions the subject is allowed to perform on resources. The list ordering isn't significant, may contain duplicates, and possibly be incomplete.", - "items": { - "$ref": "#/definitions/v1.ResourceRule" - }, - "type": "array" + "type": { + "description": "Type indicates the type of the StatefulSetUpdateStrategy. Default is RollingUpdate.", + "type": "string" } }, - "required": [ - "resourceRules", - "nonResourceRules", - "incomplete" - ], "type": "object" }, - "v1.CrossVersionObjectReference": { - "description": "CrossVersionObjectReference contains enough information to let you identify the referred resource.", + "v1.BoundObjectReference": { + "description": "BoundObjectReference is a reference to an object that a token is bound to.", "properties": { "apiVersion": { - "description": "API version of the referent", + "description": "API version of the referent.", "type": "string" }, "kind": { - "description": "Kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds\"", + "description": "Kind of the referent. Valid kinds are 'Pod' and 'Secret'.", "type": "string" }, "name": { - "description": "Name of the referent; More info: http://kubernetes.io/docs/user-guide/identifiers#names", + "description": "Name of the referent.", + "type": "string" + }, + "uid": { + "description": "UID of the referent.", "type": "string" } }, - "required": [ - "kind", - "name" - ], - "type": "object", - "x-kubernetes-map-type": "atomic" + "type": "object" }, - "v1.HorizontalPodAutoscaler": { - "description": "configuration of a horizontal pod autoscaler.", + "v1.SelfSubjectReview": { + "description": "SelfSubjectReview contains the user information that the kube-apiserver has about the user making this request. When using impersonation, users will receive the user info of the user being impersonated. If impersonation or request header authentication is used, any extra keys will have their case ignored and returned as lowercase.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", @@ -2082,127 +2865,115 @@ }, "metadata": { "$ref": "#/definitions/v1.ObjectMeta", - "description": "Standard object metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" - }, - "spec": { - "$ref": "#/definitions/v1.HorizontalPodAutoscalerSpec", - "description": "behaviour of autoscaler. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status." + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" }, "status": { - "$ref": "#/definitions/v1.HorizontalPodAutoscalerStatus", - "description": "current information about the autoscaler." + "$ref": "#/definitions/v1.SelfSubjectReviewStatus", + "description": "Status is filled in by the server with the user attributes." } }, "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "autoscaling", - "kind": "HorizontalPodAutoscaler", + "group": "authentication.k8s.io", + "kind": "SelfSubjectReview", "version": "v1" } ] }, - "v1.HorizontalPodAutoscalerList": { - "description": "list of horizontal pod autoscaler objects.", + "v1.SelfSubjectReviewStatus": { + "description": "SelfSubjectReviewStatus is filled by the kube-apiserver and sent back to a user.", + "properties": { + "userInfo": { + "$ref": "#/definitions/v1.UserInfo", + "description": "User attributes of the user making this request." + } + }, + "type": "object" + }, + "authentication.v1.TokenRequest": { + "description": "TokenRequest requests a token for a given service account.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, - "items": { - "description": "list of horizontal pod autoscaler objects.", - "items": { - "$ref": "#/definitions/v1.HorizontalPodAutoscaler" - }, - "type": "array" - }, "kind": { "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", "type": "string" }, "metadata": { - "$ref": "#/definitions/v1.ListMeta", - "description": "Standard list metadata." + "$ref": "#/definitions/v1.ObjectMeta", + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + }, + "spec": { + "$ref": "#/definitions/v1.TokenRequestSpec", + "description": "Spec holds information about the request being evaluated" + }, + "status": { + "$ref": "#/definitions/v1.TokenRequestStatus", + "description": "Status is filled in by the server and indicates whether the token can be authenticated." } }, "required": [ - "items" + "spec" ], "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "autoscaling", - "kind": "HorizontalPodAutoscalerList", + "group": "authentication.k8s.io", + "kind": "TokenRequest", "version": "v1" } ] }, - "v1.HorizontalPodAutoscalerSpec": { - "description": "specification of a horizontal pod autoscaler.", + "v1.TokenRequestSpec": { + "description": "TokenRequestSpec contains client provided parameters of a token request.", "properties": { - "maxReplicas": { - "description": "upper limit for the number of pods that can be set by the autoscaler; cannot be smaller than MinReplicas.", - "format": "int32", - "type": "integer" - }, - "minReplicas": { - "description": "minReplicas is the lower limit for the number of replicas to which the autoscaler can scale down. It defaults to 1 pod. minReplicas is allowed to be 0 if the alpha feature gate HPAScaleToZero is enabled and at least one Object or External metric is configured. Scaling is active as long as at least one metric value is available.", - "format": "int32", - "type": "integer" + "audiences": { + "description": "Audiences are the intendend audiences of the token. A recipient of a token must identify themself with an identifier in the list of audiences of the token, and otherwise should reject the token. A token issued for multiple audiences may be used to authenticate against any of the audiences listed but implies a high degree of trust between the target audiences.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" }, - "scaleTargetRef": { - "$ref": "#/definitions/v1.CrossVersionObjectReference", - "description": "reference to scaled resource; horizontal pod autoscaler will learn the current resource consumption and will set the desired number of pods by using its Scale subresource." + "boundObjectRef": { + "$ref": "#/definitions/v1.BoundObjectReference", + "description": "BoundObjectRef is a reference to an object that the token will be bound to. The token will only be valid for as long as the bound object exists. NOTE: The API server's TokenReview endpoint will validate the BoundObjectRef, but other audiences may not. Keep ExpirationSeconds small if you want prompt revocation." }, - "targetCPUUtilizationPercentage": { - "description": "target average CPU utilization (represented as a percentage of requested CPU) over all the pods; if not specified the default autoscaling policy will be used.", - "format": "int32", + "expirationSeconds": { + "description": "ExpirationSeconds is the requested duration of validity of the request. The token issuer may return a token with a different validity duration so a client needs to check the 'expiration' field in a response.", + "format": "int64", "type": "integer" } }, "required": [ - "scaleTargetRef", - "maxReplicas" + "audiences" ], "type": "object" }, - "v1.HorizontalPodAutoscalerStatus": { - "description": "current status of a horizontal pod autoscaler", + "v1.TokenRequestStatus": { + "description": "TokenRequestStatus is the result of a token request.", "properties": { - "currentCPUUtilizationPercentage": { - "description": "current average CPU utilization over all pods, represented as a percentage of requested CPU, e.g. 70 means that an average pod is using now 70% of its requested CPU.", - "format": "int32", - "type": "integer" - }, - "currentReplicas": { - "description": "current number of replicas of pods managed by this autoscaler.", - "format": "int32", - "type": "integer" - }, - "desiredReplicas": { - "description": "desired number of replicas of pods managed by this autoscaler.", - "format": "int32", - "type": "integer" - }, - "lastScaleTime": { - "description": "last time the HorizontalPodAutoscaler scaled the number of pods; used by the autoscaler to control how often the number of pods is changed.", + "expirationTimestamp": { + "description": "ExpirationTimestamp is the time of expiration of the returned token.", "format": "date-time", "type": "string" }, - "observedGeneration": { - "description": "most recent generation observed by this autoscaler.", - "format": "int64", - "type": "integer" + "token": { + "description": "Token is the opaque bearer token.", + "type": "string" } }, "required": [ - "currentReplicas", - "desiredReplicas" + "token", + "expirationTimestamp" ], "type": "object" }, - "v1.Scale": { - "description": "Scale represents a scaling request for a resource.", + "v1.TokenReview": { + "description": "TokenReview attempts to authenticate a token to a known user. Note: TokenReview requests may be cached by the webhook token authenticator plugin in the kube-apiserver.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", @@ -2214,209 +2985,301 @@ }, "metadata": { "$ref": "#/definitions/v1.ObjectMeta", - "description": "Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata." + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" }, "spec": { - "$ref": "#/definitions/v1.ScaleSpec", - "description": "defines the behavior of the scale. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status." + "$ref": "#/definitions/v1.TokenReviewSpec", + "description": "Spec holds information about the request being evaluated" }, "status": { - "$ref": "#/definitions/v1.ScaleStatus", - "description": "current status of the scale. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status. Read-only." + "$ref": "#/definitions/v1.TokenReviewStatus", + "description": "Status is filled in by the server and indicates whether the request can be authenticated." } }, + "required": [ + "spec" + ], "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "autoscaling", - "kind": "Scale", + "group": "authentication.k8s.io", + "kind": "TokenReview", "version": "v1" } ] }, - "v1.ScaleSpec": { - "description": "ScaleSpec describes the attributes of a scale subresource.", + "v1.TokenReviewSpec": { + "description": "TokenReviewSpec is a description of the token authentication request.", "properties": { - "replicas": { - "description": "desired number of instances for the scaled object.", - "format": "int32", - "type": "integer" + "audiences": { + "description": "Audiences is a list of the identifiers that the resource server presented with the token identifies as. Audience-aware token authenticators will verify that the token was intended for at least one of the audiences in this list. If no audiences are provided, the audience will default to the audience of the Kubernetes apiserver.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "token": { + "description": "Token is the opaque bearer token.", + "type": "string" } }, "type": "object" }, - "v1.ScaleStatus": { - "description": "ScaleStatus represents the current status of a scale subresource.", + "v1.TokenReviewStatus": { + "description": "TokenReviewStatus is the result of the token authentication request.", "properties": { - "replicas": { - "description": "actual number of observed instances of the scaled object.", - "format": "int32", - "type": "integer" + "audiences": { + "description": "Audiences are audience identifiers chosen by the authenticator that are compatible with both the TokenReview and token. An identifier is any identifier in the intersection of the TokenReviewSpec audiences and the token's audiences. A client of the TokenReview API that sets the spec.audiences field should validate that a compatible audience identifier is returned in the status.audiences field to ensure that the TokenReview server is audience aware. If a TokenReview returns an empty status.audience field where status.authenticated is \"true\", the token is valid against the audience of the Kubernetes API server.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" }, - "selector": { - "description": "label query over pods that should match the replicas count. This is same as the label selector but in the string format to avoid introspection by clients. The string will be in the same format as the query-param syntax. More info about label selectors: http://kubernetes.io/docs/user-guide/labels#label-selectors", + "authenticated": { + "description": "Authenticated indicates that the token was associated with a known user.", + "type": "boolean" + }, + "error": { + "description": "Error indicates that the token couldn't be checked", "type": "string" + }, + "user": { + "$ref": "#/definitions/v1.UserInfo", + "description": "User is the UserInfo associated with the provided token." } }, - "required": [ - "replicas" - ], "type": "object" }, - "v2.ContainerResourceMetricSource": { - "description": "ContainerResourceMetricSource indicates how to scale on a resource metric known to Kubernetes, as specified in requests and limits, describing each pod in the current scale target (e.g. CPU or memory). The values will be averaged together before being compared to the target. Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the \"pods\" source. Only one \"target\" type should be set.", + "v1.UserInfo": { + "description": "UserInfo holds the information about the user needed to implement the user.Info interface.", "properties": { - "container": { - "description": "container is the name of the container in the pods of the scaling target", - "type": "string" + "extra": { + "additionalProperties": { + "items": { + "type": "string" + }, + "type": "array" + }, + "description": "Any additional information provided by the authenticator.", + "type": "object" }, - "name": { - "description": "name is the name of the resource in question.", + "groups": { + "description": "The names of groups this user is a part of.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "uid": { + "description": "A unique value that identifies this user across time. If this user is deleted and another user by the same name is added, they will have different UIDs.", "type": "string" }, - "target": { - "$ref": "#/definitions/v2.MetricTarget", - "description": "target specifies the target value for the given metric" + "username": { + "description": "The name that uniquely identifies this user among all active users.", + "type": "string" } }, - "required": [ - "name", - "target", - "container" - ], "type": "object" }, - "v2.ContainerResourceMetricStatus": { - "description": "ContainerResourceMetricStatus indicates the current value of a resource metric known to Kubernetes, as specified in requests and limits, describing a single container in each pod in the current scale target (e.g. CPU or memory). Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the \"pods\" source.", + "v1.FieldSelectorAttributes": { + "description": "FieldSelectorAttributes indicates a field limited access. Webhook authors are encouraged to * ensure rawSelector and requirements are not both set * consider the requirements field if set * not try to parse or consider the rawSelector field if set. This is to avoid another CVE-2022-2880 (i.e. getting different systems to agree on how exactly to parse a query is not something we want), see https://www.oxeye.io/resources/golang-parameter-smuggling-attack for more details. For the *SubjectAccessReview endpoints of the kube-apiserver: * If rawSelector is empty and requirements are empty, the request is not limited. * If rawSelector is present and requirements are empty, the rawSelector will be parsed and limited if the parsing succeeds. * If rawSelector is empty and requirements are present, the requirements should be honored * If rawSelector is present and requirements are present, the request is invalid.", "properties": { - "container": { - "description": "Container is the name of the container in the pods of the scaling target", + "rawSelector": { + "description": "rawSelector is the serialization of a field selector that would be included in a query parameter. Webhook implementations are encouraged to ignore rawSelector. The kube-apiserver's *SubjectAccessReview will parse the rawSelector as long as the requirements are not present.", "type": "string" }, - "current": { - "$ref": "#/definitions/v2.MetricValueStatus", - "description": "current contains the current value for the given metric" - }, - "name": { - "description": "Name is the name of the resource in question.", - "type": "string" - } + "requirements": { + "description": "requirements is the parsed interpretation of a field selector. All requirements must be met for a resource instance to match the selector. Webhook implementations should handle requirements, but how to handle them is up to the webhook. Since requirements can only limit the request, it is safe to authorize as unlimited request if the requirements are not understood.", + "items": { + "$ref": "#/definitions/v1.FieldSelectorRequirement" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + } }, - "required": [ - "name", - "current", - "container" - ], "type": "object" }, - "v2.CrossVersionObjectReference": { - "description": "CrossVersionObjectReference contains enough information to let you identify the referred resource.", + "v1.LabelSelectorAttributes": { + "description": "LabelSelectorAttributes indicates a label limited access. Webhook authors are encouraged to * ensure rawSelector and requirements are not both set * consider the requirements field if set * not try to parse or consider the rawSelector field if set. This is to avoid another CVE-2022-2880 (i.e. getting different systems to agree on how exactly to parse a query is not something we want), see https://www.oxeye.io/resources/golang-parameter-smuggling-attack for more details. For the *SubjectAccessReview endpoints of the kube-apiserver: * If rawSelector is empty and requirements are empty, the request is not limited. * If rawSelector is present and requirements are empty, the rawSelector will be parsed and limited if the parsing succeeds. * If rawSelector is empty and requirements are present, the requirements should be honored * If rawSelector is present and requirements are present, the request is invalid.", + "properties": { + "rawSelector": { + "description": "rawSelector is the serialization of a field selector that would be included in a query parameter. Webhook implementations are encouraged to ignore rawSelector. The kube-apiserver's *SubjectAccessReview will parse the rawSelector as long as the requirements are not present.", + "type": "string" + }, + "requirements": { + "description": "requirements is the parsed interpretation of a label selector. All requirements must be met for a resource instance to match the selector. Webhook implementations should handle requirements, but how to handle them is up to the webhook. Since requirements can only limit the request, it is safe to authorize as unlimited request if the requirements are not understood.", + "items": { + "$ref": "#/definitions/v1.LabelSelectorRequirement" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + } + }, + "type": "object" + }, + "v1.LocalSubjectAccessReview": { + "description": "LocalSubjectAccessReview checks whether or not a user or group can perform an action in a given namespace. Having a namespace scoped resource makes it much easier to grant namespace scoped policy that includes permissions checking.", "properties": { "apiVersion": { - "description": "API version of the referent", + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, "kind": { - "description": "Kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds\"", + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", "type": "string" }, - "name": { - "description": "Name of the referent; More info: http://kubernetes.io/docs/user-guide/identifiers#names", - "type": "string" + "metadata": { + "$ref": "#/definitions/v1.ObjectMeta", + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + }, + "spec": { + "$ref": "#/definitions/v1.SubjectAccessReviewSpec", + "description": "Spec holds information about the request being evaluated. spec.namespace must be equal to the namespace you made the request against. If empty, it is defaulted." + }, + "status": { + "$ref": "#/definitions/v1.SubjectAccessReviewStatus", + "description": "Status is filled in by the server and indicates whether the request is allowed or not" } }, "required": [ - "kind", - "name" + "spec" ], - "type": "object" + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "authorization.k8s.io", + "kind": "LocalSubjectAccessReview", + "version": "v1" + } + ] }, - "v2.ExternalMetricSource": { - "description": "ExternalMetricSource indicates how to scale on a metric not associated with any Kubernetes object (for example length of queue in cloud messaging service, or QPS from loadbalancer running outside of cluster).", + "v1.NonResourceAttributes": { + "description": "NonResourceAttributes includes the authorization attributes available for non-resource requests to the Authorizer interface", "properties": { - "metric": { - "$ref": "#/definitions/v2.MetricIdentifier", - "description": "metric identifies the target metric by name and selector" + "path": { + "description": "Path is the URL path of the request", + "type": "string" }, - "target": { - "$ref": "#/definitions/v2.MetricTarget", - "description": "target specifies the target value for the given metric" + "verb": { + "description": "Verb is the standard HTTP verb", + "type": "string" } }, - "required": [ - "metric", - "target" - ], "type": "object" }, - "v2.ExternalMetricStatus": { - "description": "ExternalMetricStatus indicates the current value of a global metric not associated with any Kubernetes object.", + "v1.NonResourceRule": { + "description": "NonResourceRule holds information that describes a rule for the non-resource", "properties": { - "current": { - "$ref": "#/definitions/v2.MetricValueStatus", - "description": "current contains the current value for the given metric" + "nonResourceURLs": { + "description": "NonResourceURLs is a set of partial urls that a user should have access to. *s are allowed, but only as the full, final step in the path. \"*\" means all.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" }, - "metric": { - "$ref": "#/definitions/v2.MetricIdentifier", - "description": "metric identifies the target metric by name and selector" + "verbs": { + "description": "Verb is a list of kubernetes non-resource API verbs, like: get, post, put, delete, patch, head, options. \"*\" means all.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "required": [ - "metric", - "current" + "verbs" ], "type": "object" }, - "v2.HPAScalingPolicy": { - "description": "HPAScalingPolicy is a single policy which must hold true for a specified past interval.", + "v1.ResourceAttributes": { + "description": "ResourceAttributes includes the authorization attributes available for resource requests to the Authorizer interface", "properties": { - "periodSeconds": { - "description": "PeriodSeconds specifies the window of time for which the policy should hold true. PeriodSeconds must be greater than zero and less than or equal to 1800 (30 min).", - "format": "int32", - "type": "integer" + "fieldSelector": { + "$ref": "#/definitions/v1.FieldSelectorAttributes", + "description": "fieldSelector describes the limitation on access based on field. It can only limit access, not broaden it." }, - "type": { - "description": "Type is used to specify the scaling policy.", + "group": { + "description": "Group is the API Group of the Resource. \"*\" means all.", "type": "string" }, - "value": { - "description": "Value contains the amount of change which is permitted by the policy. It must be greater than zero", - "format": "int32", - "type": "integer" + "labelSelector": { + "$ref": "#/definitions/v1.LabelSelectorAttributes", + "description": "labelSelector describes the limitation on access based on labels. It can only limit access, not broaden it." + }, + "name": { + "description": "Name is the name of the resource being requested for a \"get\" or deleted for a \"delete\". \"\" (empty) means all.", + "type": "string" + }, + "namespace": { + "description": "Namespace is the namespace of the action being requested. Currently, there is no distinction between no namespace and all namespaces \"\" (empty) is defaulted for LocalSubjectAccessReviews \"\" (empty) is empty for cluster-scoped resources \"\" (empty) means \"all\" for namespace scoped resources from a SubjectAccessReview or SelfSubjectAccessReview", + "type": "string" + }, + "resource": { + "description": "Resource is one of the existing resource types. \"*\" means all.", + "type": "string" + }, + "subresource": { + "description": "Subresource is one of the existing resource types. \"\" means none.", + "type": "string" + }, + "verb": { + "description": "Verb is a kubernetes resource API verb, like: get, list, watch, create, update, delete, proxy. \"*\" means all.", + "type": "string" + }, + "version": { + "description": "Version is the API Version of the Resource. \"*\" means all.", + "type": "string" } }, - "required": [ - "type", - "value", - "periodSeconds" - ], "type": "object" }, - "v2.HPAScalingRules": { - "description": "HPAScalingRules configures the scaling behavior for one direction. These Rules are applied after calculating DesiredReplicas from metrics for the HPA. They can limit the scaling velocity by specifying scaling policies. They can prevent flapping by specifying the stabilization window, so that the number of replicas is not set instantly, instead, the safest value from the stabilization window is chosen.", + "v1.ResourceRule": { + "description": "ResourceRule is the list of actions the subject is allowed to perform on resources. The list ordering isn't significant, may contain duplicates, and possibly be incomplete.", "properties": { - "policies": { - "description": "policies is a list of potential scaling polices which can be used during scaling. At least one policy must be specified, otherwise the HPAScalingRules will be discarded as invalid", + "apiGroups": { + "description": "APIGroups is the name of the APIGroup that contains the resources. If multiple API groups are specified, any action requested against one of the enumerated resources in any API group will be allowed. \"*\" means all.", "items": { - "$ref": "#/definitions/v2.HPAScalingPolicy" + "type": "string" }, "type": "array", "x-kubernetes-list-type": "atomic" }, - "selectPolicy": { - "description": "selectPolicy is used to specify which policy should be used. If not set, the default value Max is used.", - "type": "string" + "resourceNames": { + "description": "ResourceNames is an optional white list of names that the rule applies to. An empty set means that everything is allowed. \"*\" means all.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" }, - "stabilizationWindowSeconds": { - "description": "StabilizationWindowSeconds is the number of seconds for which past recommendations should be considered while scaling up or scaling down. StabilizationWindowSeconds must be greater than or equal to zero and less than or equal to 3600 (one hour). If not set, use the default values: - For scale up: 0 (i.e. no stabilization is done). - For scale down: 300 (i.e. the stabilization window is 300 seconds long).", - "format": "int32", - "type": "integer" + "resources": { + "description": "Resources is a list of resources this rule applies to. \"*\" means all in the specified apiGroups.\n \"*/foo\" represents the subresource 'foo' for all resources in the specified apiGroups.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "verbs": { + "description": "Verb is a list of kubernetes resource API verbs, like: get, list, watch, create, update, delete, proxy. \"*\" means all.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" } }, + "required": [ + "verbs" + ], "type": "object" }, - "v2.HorizontalPodAutoscaler": { - "description": "HorizontalPodAutoscaler is the configuration for a horizontal pod autoscaler, which automatically manages the replica count of any resource implementing the scale subresource based on the metrics specified.", + "v1.SelfSubjectAccessReview": { + "description": "SelfSubjectAccessReview checks whether or the current user can perform an action. Not filling in a spec.namespace means \"in all namespaces\". Self is a special case, because users should always be able to check whether they can perform an action", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", @@ -2428,439 +3291,443 @@ }, "metadata": { "$ref": "#/definitions/v1.ObjectMeta", - "description": "metadata is the standard object metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" }, "spec": { - "$ref": "#/definitions/v2.HorizontalPodAutoscalerSpec", - "description": "spec is the specification for the behaviour of the autoscaler. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status." + "$ref": "#/definitions/v1.SelfSubjectAccessReviewSpec", + "description": "Spec holds information about the request being evaluated. user and groups must be empty" }, "status": { - "$ref": "#/definitions/v2.HorizontalPodAutoscalerStatus", - "description": "status is the current information about the autoscaler." + "$ref": "#/definitions/v1.SubjectAccessReviewStatus", + "description": "Status is filled in by the server and indicates whether the request is allowed or not" } }, + "required": [ + "spec" + ], "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "autoscaling", - "kind": "HorizontalPodAutoscaler", - "version": "v2" + "group": "authorization.k8s.io", + "kind": "SelfSubjectAccessReview", + "version": "v1" } ] }, - "v2.HorizontalPodAutoscalerBehavior": { - "description": "HorizontalPodAutoscalerBehavior configures the scaling behavior of the target in both Up and Down directions (scaleUp and scaleDown fields respectively).", + "v1.SelfSubjectAccessReviewSpec": { + "description": "SelfSubjectAccessReviewSpec is a description of the access request. Exactly one of ResourceAuthorizationAttributes and NonResourceAuthorizationAttributes must be set", "properties": { - "scaleDown": { - "$ref": "#/definitions/v2.HPAScalingRules", - "description": "scaleDown is scaling policy for scaling Down. If not set, the default value is to allow to scale down to minReplicas pods, with a 300 second stabilization window (i.e., the highest recommendation for the last 300sec is used)." + "nonResourceAttributes": { + "$ref": "#/definitions/v1.NonResourceAttributes", + "description": "NonResourceAttributes describes information for a non-resource access request" }, - "scaleUp": { - "$ref": "#/definitions/v2.HPAScalingRules", - "description": "scaleUp is scaling policy for scaling Up. If not set, the default value is the higher of:\n * increase no more than 4 pods per 60 seconds\n * double the number of pods per 60 seconds\nNo stabilization is used." + "resourceAttributes": { + "$ref": "#/definitions/v1.ResourceAttributes", + "description": "ResourceAuthorizationAttributes describes information for a resource access request" } }, "type": "object" }, - "v2.HorizontalPodAutoscalerCondition": { - "description": "HorizontalPodAutoscalerCondition describes the state of a HorizontalPodAutoscaler at a certain point.", + "v1.SelfSubjectRulesReview": { + "description": "SelfSubjectRulesReview enumerates the set of actions the current user can perform within a namespace. The returned list of actions may be incomplete depending on the server's authorization mode, and any errors experienced during the evaluation. SelfSubjectRulesReview should be used by UIs to show/hide actions, or to quickly let an end user reason about their permissions. It should NOT Be used by external systems to drive authorization decisions as this raises confused deputy, cache lifetime/revocation, and correctness concerns. SubjectAccessReview, and LocalAccessReview are the correct way to defer authorization decisions to the API server.", "properties": { - "lastTransitionTime": { - "description": "lastTransitionTime is the last time the condition transitioned from one status to another", - "format": "date-time", + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, - "message": { - "description": "message is a human-readable explanation containing details about the transition", + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", "type": "string" }, - "reason": { - "description": "reason is the reason for the condition's last transition.", - "type": "string" + "metadata": { + "$ref": "#/definitions/v1.ObjectMeta", + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" }, - "status": { - "description": "status is the status of the condition (True, False, Unknown)", - "type": "string" + "spec": { + "$ref": "#/definitions/v1.SelfSubjectRulesReviewSpec", + "description": "Spec holds information about the request being evaluated." }, - "type": { - "description": "type describes the current condition", - "type": "string" + "status": { + "$ref": "#/definitions/v1.SubjectRulesReviewStatus", + "description": "Status is filled in by the server and indicates the set of actions a user can perform." } }, "required": [ - "type", - "status" + "spec" ], + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "authorization.k8s.io", + "kind": "SelfSubjectRulesReview", + "version": "v1" + } + ] + }, + "v1.SelfSubjectRulesReviewSpec": { + "description": "SelfSubjectRulesReviewSpec defines the specification for SelfSubjectRulesReview.", + "properties": { + "namespace": { + "description": "Namespace to evaluate rules for. Required.", + "type": "string" + } + }, "type": "object" }, - "v2.HorizontalPodAutoscalerList": { - "description": "HorizontalPodAutoscalerList is a list of horizontal pod autoscaler objects.", + "v1.SubjectAccessReview": { + "description": "SubjectAccessReview checks whether or not a user or group can perform an action.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, - "items": { - "description": "items is the list of horizontal pod autoscaler objects.", - "items": { - "$ref": "#/definitions/v2.HorizontalPodAutoscaler" - }, - "type": "array" - }, "kind": { "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", "type": "string" }, "metadata": { - "$ref": "#/definitions/v1.ListMeta", - "description": "metadata is the standard list metadata." + "$ref": "#/definitions/v1.ObjectMeta", + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + }, + "spec": { + "$ref": "#/definitions/v1.SubjectAccessReviewSpec", + "description": "Spec holds information about the request being evaluated" + }, + "status": { + "$ref": "#/definitions/v1.SubjectAccessReviewStatus", + "description": "Status is filled in by the server and indicates whether the request is allowed or not" } }, "required": [ - "items" + "spec" ], "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "autoscaling", - "kind": "HorizontalPodAutoscalerList", - "version": "v2" + "group": "authorization.k8s.io", + "kind": "SubjectAccessReview", + "version": "v1" } ] }, - "v2.HorizontalPodAutoscalerSpec": { - "description": "HorizontalPodAutoscalerSpec describes the desired functionality of the HorizontalPodAutoscaler.", + "v1.SubjectAccessReviewSpec": { + "description": "SubjectAccessReviewSpec is a description of the access request. Exactly one of ResourceAuthorizationAttributes and NonResourceAuthorizationAttributes must be set", "properties": { - "behavior": { - "$ref": "#/definitions/v2.HorizontalPodAutoscalerBehavior", - "description": "behavior configures the scaling behavior of the target in both Up and Down directions (scaleUp and scaleDown fields respectively). If not set, the default HPAScalingRules for scale up and scale down are used." - }, - "maxReplicas": { - "description": "maxReplicas is the upper limit for the number of replicas to which the autoscaler can scale up. It cannot be less that minReplicas.", - "format": "int32", - "type": "integer" + "extra": { + "additionalProperties": { + "items": { + "type": "string" + }, + "type": "array" + }, + "description": "Extra corresponds to the user.Info.GetExtra() method from the authenticator. Since that is input to the authorizer it needs a reflection here.", + "type": "object" }, - "metrics": { - "description": "metrics contains the specifications for which to use to calculate the desired replica count (the maximum replica count across all metrics will be used). The desired replica count is calculated multiplying the ratio between the target value and the current value by the current number of pods. Ergo, metrics used must decrease as the pod count is increased, and vice-versa. See the individual metric source types for more information about how each type of metric must respond. If not set, the default metric will be set to 80% average CPU utilization.", + "groups": { + "description": "Groups is the groups you're testing for.", "items": { - "$ref": "#/definitions/v2.MetricSpec" + "type": "string" }, "type": "array", "x-kubernetes-list-type": "atomic" }, - "minReplicas": { - "description": "minReplicas is the lower limit for the number of replicas to which the autoscaler can scale down. It defaults to 1 pod. minReplicas is allowed to be 0 if the alpha feature gate HPAScaleToZero is enabled and at least one Object or External metric is configured. Scaling is active as long as at least one metric value is available.", - "format": "int32", - "type": "integer" + "nonResourceAttributes": { + "$ref": "#/definitions/v1.NonResourceAttributes", + "description": "NonResourceAttributes describes information for a non-resource access request" }, - "scaleTargetRef": { - "$ref": "#/definitions/v2.CrossVersionObjectReference", - "description": "scaleTargetRef points to the target resource to scale, and is used to the pods for which metrics should be collected, as well as to actually change the replica count." + "resourceAttributes": { + "$ref": "#/definitions/v1.ResourceAttributes", + "description": "ResourceAuthorizationAttributes describes information for a resource access request" + }, + "uid": { + "description": "UID information about the requesting user.", + "type": "string" + }, + "user": { + "description": "User is the user you're testing for. If you specify \"User\" but not \"Groups\", then is it interpreted as \"What if User were not a member of any groups", + "type": "string" } }, - "required": [ - "scaleTargetRef", - "maxReplicas" - ], "type": "object" }, - "v2.HorizontalPodAutoscalerStatus": { - "description": "HorizontalPodAutoscalerStatus describes the current status of a horizontal pod autoscaler.", + "v1.SubjectAccessReviewStatus": { + "description": "SubjectAccessReviewStatus", "properties": { - "conditions": { - "description": "conditions is the set of conditions required for this autoscaler to scale its target, and indicates whether or not those conditions are met.", - "items": { - "$ref": "#/definitions/v2.HorizontalPodAutoscalerCondition" - }, - "type": "array", - "x-kubernetes-list-map-keys": [ - "type" - ], - "x-kubernetes-list-type": "map", - "x-kubernetes-patch-merge-key": "type", - "x-kubernetes-patch-strategy": "merge" - }, - "currentMetrics": { - "description": "currentMetrics is the last read state of the metrics used by this autoscaler.", - "items": { - "$ref": "#/definitions/v2.MetricStatus" - }, - "type": "array", - "x-kubernetes-list-type": "atomic" - }, - "currentReplicas": { - "description": "currentReplicas is current number of replicas of pods managed by this autoscaler, as last seen by the autoscaler.", - "format": "int32", - "type": "integer" + "allowed": { + "description": "Allowed is required. True if the action would be allowed, false otherwise.", + "type": "boolean" }, - "desiredReplicas": { - "description": "desiredReplicas is the desired number of replicas of pods managed by this autoscaler, as last calculated by the autoscaler.", - "format": "int32", - "type": "integer" + "denied": { + "description": "Denied is optional. True if the action would be denied, otherwise false. If both allowed is false and denied is false, then the authorizer has no opinion on whether to authorize the action. Denied may not be true if Allowed is true.", + "type": "boolean" }, - "lastScaleTime": { - "description": "lastScaleTime is the last time the HorizontalPodAutoscaler scaled the number of pods, used by the autoscaler to control how often the number of pods is changed.", - "format": "date-time", + "evaluationError": { + "description": "EvaluationError is an indication that some error occurred during the authorization check. It is entirely possible to get an error and be able to continue determine authorization status in spite of it. For instance, RBAC can be missing a role, but enough roles are still present and bound to reason about the request.", "type": "string" }, - "observedGeneration": { - "description": "observedGeneration is the most recent generation observed by this autoscaler.", - "format": "int64", - "type": "integer" + "reason": { + "description": "Reason is optional. It indicates why a request was allowed or denied.", + "type": "string" } }, "required": [ - "desiredReplicas" + "allowed" ], "type": "object" }, - "v2.MetricIdentifier": { - "description": "MetricIdentifier defines the name and optionally selector for a metric", + "v1.SubjectRulesReviewStatus": { + "description": "SubjectRulesReviewStatus contains the result of a rules check. This check can be incomplete depending on the set of authorizers the server is configured with and any errors experienced during evaluation. Because authorization rules are additive, if a rule appears in a list it's safe to assume the subject has that permission, even if that list is incomplete.", "properties": { - "name": { - "description": "name is the name of the given metric", + "evaluationError": { + "description": "EvaluationError can appear in combination with Rules. It indicates an error occurred during rule evaluation, such as an authorizer that doesn't support rule evaluation, and that ResourceRules and/or NonResourceRules may be incomplete.", "type": "string" }, - "selector": { - "$ref": "#/definitions/v1.LabelSelector", - "description": "selector is the string-encoded form of a standard kubernetes label selector for the given metric When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping. When unset, just the metricName will be used to gather metrics." + "incomplete": { + "description": "Incomplete is true when the rules returned by this call are incomplete. This is most commonly encountered when an authorizer, such as an external authorizer, doesn't support rules evaluation.", + "type": "boolean" + }, + "nonResourceRules": { + "description": "NonResourceRules is the list of actions the subject is allowed to perform on non-resources. The list ordering isn't significant, may contain duplicates, and possibly be incomplete.", + "items": { + "$ref": "#/definitions/v1.NonResourceRule" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "resourceRules": { + "description": "ResourceRules is the list of actions the subject is allowed to perform on resources. The list ordering isn't significant, may contain duplicates, and possibly be incomplete.", + "items": { + "$ref": "#/definitions/v1.ResourceRule" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "required": [ - "name" + "resourceRules", + "nonResourceRules", + "incomplete" ], "type": "object" }, - "v2.MetricSpec": { - "description": "MetricSpec specifies how to scale based on a single metric (only `type` and one other matching field should be set at once).", + "v1.CrossVersionObjectReference": { + "description": "CrossVersionObjectReference contains enough information to let you identify the referred resource.", "properties": { - "containerResource": { - "$ref": "#/definitions/v2.ContainerResourceMetricSource", - "description": "containerResource refers to a resource metric (such as those specified in requests and limits) known to Kubernetes describing a single container in each pod of the current scale target (e.g. CPU or memory). Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the \"pods\" source. This is an alpha feature and can be enabled by the HPAContainerMetrics feature flag." - }, - "external": { - "$ref": "#/definitions/v2.ExternalMetricSource", - "description": "external refers to a global metric that is not associated with any Kubernetes object. It allows autoscaling based on information coming from components running outside of cluster (for example length of queue in cloud messaging service, or QPS from loadbalancer running outside of cluster)." - }, - "object": { - "$ref": "#/definitions/v2.ObjectMetricSource", - "description": "object refers to a metric describing a single kubernetes object (for example, hits-per-second on an Ingress object)." - }, - "pods": { - "$ref": "#/definitions/v2.PodsMetricSource", - "description": "pods refers to a metric describing each pod in the current scale target (for example, transactions-processed-per-second). The values will be averaged together before being compared to the target value." + "apiVersion": { + "description": "apiVersion is the API version of the referent", + "type": "string" }, - "resource": { - "$ref": "#/definitions/v2.ResourceMetricSource", - "description": "resource refers to a resource metric (such as those specified in requests and limits) known to Kubernetes describing each pod in the current scale target (e.g. CPU or memory). Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the \"pods\" source." + "kind": { + "description": "kind is the kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" }, - "type": { - "description": "type is the type of metric source. It should be one of \"ContainerResource\", \"External\", \"Object\", \"Pods\" or \"Resource\", each mapping to a matching field in the object. Note: \"ContainerResource\" type is available on when the feature-gate HPAContainerMetrics is enabled", + "name": { + "description": "name is the name of the referent; More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", "type": "string" } }, "required": [ - "type" + "kind", + "name" ], - "type": "object" + "type": "object", + "x-kubernetes-map-type": "atomic" }, - "v2.MetricStatus": { - "description": "MetricStatus describes the last-read state of a single metric.", + "v1.HorizontalPodAutoscaler": { + "description": "configuration of a horizontal pod autoscaler.", "properties": { - "containerResource": { - "$ref": "#/definitions/v2.ContainerResourceMetricStatus", - "description": "container resource refers to a resource metric (such as those specified in requests and limits) known to Kubernetes describing a single container in each pod in the current scale target (e.g. CPU or memory). Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the \"pods\" source." - }, - "external": { - "$ref": "#/definitions/v2.ExternalMetricStatus", - "description": "external refers to a global metric that is not associated with any Kubernetes object. It allows autoscaling based on information coming from components running outside of cluster (for example length of queue in cloud messaging service, or QPS from loadbalancer running outside of cluster)." + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" }, - "object": { - "$ref": "#/definitions/v2.ObjectMetricStatus", - "description": "object refers to a metric describing a single kubernetes object (for example, hits-per-second on an Ingress object)." + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" }, - "pods": { - "$ref": "#/definitions/v2.PodsMetricStatus", - "description": "pods refers to a metric describing each pod in the current scale target (for example, transactions-processed-per-second). The values will be averaged together before being compared to the target value." + "metadata": { + "$ref": "#/definitions/v1.ObjectMeta", + "description": "Standard object metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" }, - "resource": { - "$ref": "#/definitions/v2.ResourceMetricStatus", - "description": "resource refers to a resource metric (such as those specified in requests and limits) known to Kubernetes describing each pod in the current scale target (e.g. CPU or memory). Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the \"pods\" source." + "spec": { + "$ref": "#/definitions/v1.HorizontalPodAutoscalerSpec", + "description": "spec defines the behaviour of autoscaler. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status." }, - "type": { - "description": "type is the type of metric source. It will be one of \"ContainerResource\", \"External\", \"Object\", \"Pods\" or \"Resource\", each corresponds to a matching field in the object. Note: \"ContainerResource\" type is available on when the feature-gate HPAContainerMetrics is enabled", - "type": "string" + "status": { + "$ref": "#/definitions/v1.HorizontalPodAutoscalerStatus", + "description": "status is the current information about the autoscaler." } }, - "required": [ - "type" - ], - "type": "object" + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "autoscaling", + "kind": "HorizontalPodAutoscaler", + "version": "v1" + } + ] }, - "v2.MetricTarget": { - "description": "MetricTarget defines the target value, average value, or average utilization of a specific metric", + "v1.HorizontalPodAutoscalerList": { + "description": "list of horizontal pod autoscaler objects.", "properties": { - "averageUtilization": { - "description": "averageUtilization is the target value of the average of the resource metric across all relevant pods, represented as a percentage of the requested value of the resource for the pods. Currently only valid for Resource metric source type", - "format": "int32", - "type": "integer" + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" }, - "averageValue": { - "$ref": "#/definitions/resource.Quantity", - "description": "averageValue is the target value of the average of the metric across all relevant pods (as a quantity)" + "items": { + "description": "items is the list of horizontal pod autoscaler objects.", + "items": { + "$ref": "#/definitions/v1.HorizontalPodAutoscaler" + }, + "type": "array" }, - "type": { - "description": "type represents whether the metric type is Utilization, Value, or AverageValue", + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", "type": "string" }, - "value": { - "$ref": "#/definitions/resource.Quantity", - "description": "value is the target value of the metric (as a quantity)." + "metadata": { + "$ref": "#/definitions/v1.ListMeta", + "description": "Standard list metadata." } }, "required": [ - "type" + "items" ], - "type": "object" + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "autoscaling", + "kind": "HorizontalPodAutoscalerList", + "version": "v1" + } + ] }, - "v2.MetricValueStatus": { - "description": "MetricValueStatus holds the current value for a metric", + "v1.HorizontalPodAutoscalerSpec": { + "description": "specification of a horizontal pod autoscaler.", "properties": { - "averageUtilization": { - "description": "currentAverageUtilization is the current value of the average of the resource metric across all relevant pods, represented as a percentage of the requested value of the resource for the pods.", + "maxReplicas": { + "description": "maxReplicas is the upper limit for the number of pods that can be set by the autoscaler; cannot be smaller than MinReplicas.", "format": "int32", "type": "integer" }, - "averageValue": { - "$ref": "#/definitions/resource.Quantity", - "description": "averageValue is the current value of the average of the metric across all relevant pods (as a quantity)" - }, - "value": { - "$ref": "#/definitions/resource.Quantity", - "description": "value is the current value of the metric (as a quantity)." - } - }, - "type": "object" - }, - "v2.ObjectMetricSource": { - "description": "ObjectMetricSource indicates how to scale on a metric describing a kubernetes object (for example, hits-per-second on an Ingress object).", - "properties": { - "describedObject": { - "$ref": "#/definitions/v2.CrossVersionObjectReference", - "description": "describedObject specifies the descriptions of a object,such as kind,name apiVersion" + "minReplicas": { + "description": "minReplicas is the lower limit for the number of replicas to which the autoscaler can scale down. It defaults to 1 pod. minReplicas is allowed to be 0 if the alpha feature gate HPAScaleToZero is enabled and at least one Object or External metric is configured. Scaling is active as long as at least one metric value is available.", + "format": "int32", + "type": "integer" }, - "metric": { - "$ref": "#/definitions/v2.MetricIdentifier", - "description": "metric identifies the target metric by name and selector" + "scaleTargetRef": { + "$ref": "#/definitions/v1.CrossVersionObjectReference", + "description": "reference to scaled resource; horizontal pod autoscaler will learn the current resource consumption and will set the desired number of pods by using its Scale subresource." }, - "target": { - "$ref": "#/definitions/v2.MetricTarget", - "description": "target specifies the target value for the given metric" + "targetCPUUtilizationPercentage": { + "description": "targetCPUUtilizationPercentage is the target average CPU utilization (represented as a percentage of requested CPU) over all the pods; if not specified the default autoscaling policy will be used.", + "format": "int32", + "type": "integer" } }, "required": [ - "describedObject", - "target", - "metric" + "scaleTargetRef", + "maxReplicas" ], "type": "object" }, - "v2.ObjectMetricStatus": { - "description": "ObjectMetricStatus indicates the current value of a metric describing a kubernetes object (for example, hits-per-second on an Ingress object).", + "v1.HorizontalPodAutoscalerStatus": { + "description": "current status of a horizontal pod autoscaler", "properties": { - "current": { - "$ref": "#/definitions/v2.MetricValueStatus", - "description": "current contains the current value for the given metric" + "currentCPUUtilizationPercentage": { + "description": "currentCPUUtilizationPercentage is the current average CPU utilization over all pods, represented as a percentage of requested CPU, e.g. 70 means that an average pod is using now 70% of its requested CPU.", + "format": "int32", + "type": "integer" }, - "describedObject": { - "$ref": "#/definitions/v2.CrossVersionObjectReference", - "description": "DescribedObject specifies the descriptions of a object,such as kind,name apiVersion" + "currentReplicas": { + "description": "currentReplicas is the current number of replicas of pods managed by this autoscaler.", + "format": "int32", + "type": "integer" }, - "metric": { - "$ref": "#/definitions/v2.MetricIdentifier", - "description": "metric identifies the target metric by name and selector" - } - }, - "required": [ - "metric", - "current", - "describedObject" - ], - "type": "object" - }, - "v2.PodsMetricSource": { - "description": "PodsMetricSource indicates how to scale on a metric describing each pod in the current scale target (for example, transactions-processed-per-second). The values will be averaged together before being compared to the target value.", - "properties": { - "metric": { - "$ref": "#/definitions/v2.MetricIdentifier", - "description": "metric identifies the target metric by name and selector" + "desiredReplicas": { + "description": "desiredReplicas is the desired number of replicas of pods managed by this autoscaler.", + "format": "int32", + "type": "integer" }, - "target": { - "$ref": "#/definitions/v2.MetricTarget", - "description": "target specifies the target value for the given metric" + "lastScaleTime": { + "description": "lastScaleTime is the last time the HorizontalPodAutoscaler scaled the number of pods; used by the autoscaler to control how often the number of pods is changed.", + "format": "date-time", + "type": "string" + }, + "observedGeneration": { + "description": "observedGeneration is the most recent generation observed by this autoscaler.", + "format": "int64", + "type": "integer" } }, "required": [ - "metric", - "target" + "currentReplicas", + "desiredReplicas" ], "type": "object" }, - "v2.PodsMetricStatus": { - "description": "PodsMetricStatus indicates the current value of a metric describing each pod in the current scale target (for example, transactions-processed-per-second).", + "v1.Scale": { + "description": "Scale represents a scaling request for a resource.", "properties": { - "current": { - "$ref": "#/definitions/v2.MetricValueStatus", - "description": "current contains the current value for the given metric" + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" }, - "metric": { - "$ref": "#/definitions/v2.MetricIdentifier", - "description": "metric identifies the target metric by name and selector" + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/v1.ObjectMeta", + "description": "Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata." + }, + "spec": { + "$ref": "#/definitions/v1.ScaleSpec", + "description": "spec defines the behavior of the scale. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status." + }, + "status": { + "$ref": "#/definitions/v1.ScaleStatus", + "description": "status is the current status of the scale. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status. Read-only." } }, - "required": [ - "metric", - "current" - ], - "type": "object" + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "autoscaling", + "kind": "Scale", + "version": "v1" + } + ] }, - "v2.ResourceMetricSource": { - "description": "ResourceMetricSource indicates how to scale on a resource metric known to Kubernetes, as specified in requests and limits, describing each pod in the current scale target (e.g. CPU or memory). The values will be averaged together before being compared to the target. Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the \"pods\" source. Only one \"target\" type should be set.", + "v1.ScaleSpec": { + "description": "ScaleSpec describes the attributes of a scale subresource.", "properties": { - "name": { - "description": "name is the name of the resource in question.", - "type": "string" - }, - "target": { - "$ref": "#/definitions/v2.MetricTarget", - "description": "target specifies the target value for the given metric" + "replicas": { + "description": "replicas is the desired number of instances for the scaled object.", + "format": "int32", + "type": "integer" } }, - "required": [ - "name", - "target" - ], "type": "object" }, - "v2.ResourceMetricStatus": { - "description": "ResourceMetricStatus indicates the current value of a resource metric known to Kubernetes, as specified in requests and limits, describing each pod in the current scale target (e.g. CPU or memory). Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the \"pods\" source.", + "v1.ScaleStatus": { + "description": "ScaleStatus represents the current status of a scale subresource.", "properties": { - "current": { - "$ref": "#/definitions/v2.MetricValueStatus", - "description": "current contains the current value for the given metric" + "replicas": { + "description": "replicas is the actual number of observed instances of the scaled object.", + "format": "int32", + "type": "integer" }, - "name": { - "description": "Name is the name of the resource in question.", + "selector": { + "description": "selector is the label query over pods that should match the replicas count. This is same as the label selector but in the string format to avoid introspection by clients. The string will be in the same format as the query-param syntax. More info about label selectors: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/", "type": "string" } }, "required": [ - "name", - "current" + "replicas" ], "type": "object" }, - "v2beta2.ContainerResourceMetricSource": { + "v2.ContainerResourceMetricSource": { "description": "ContainerResourceMetricSource indicates how to scale on a resource metric known to Kubernetes, as specified in requests and limits, describing each pod in the current scale target (e.g. CPU or memory). The values will be averaged together before being compared to the target. Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the \"pods\" source. Only one \"target\" type should be set.", "properties": { "container": { @@ -2872,7 +3739,7 @@ "type": "string" }, "target": { - "$ref": "#/definitions/v2beta2.MetricTarget", + "$ref": "#/definitions/v2.MetricTarget", "description": "target specifies the target value for the given metric" } }, @@ -2883,19 +3750,19 @@ ], "type": "object" }, - "v2beta2.ContainerResourceMetricStatus": { + "v2.ContainerResourceMetricStatus": { "description": "ContainerResourceMetricStatus indicates the current value of a resource metric known to Kubernetes, as specified in requests and limits, describing a single container in each pod in the current scale target (e.g. CPU or memory). Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the \"pods\" source.", "properties": { "container": { - "description": "Container is the name of the container in the pods of the scaling target", + "description": "container is the name of the container in the pods of the scaling target", "type": "string" }, "current": { - "$ref": "#/definitions/v2beta2.MetricValueStatus", + "$ref": "#/definitions/v2.MetricValueStatus", "description": "current contains the current value for the given metric" }, "name": { - "description": "Name is the name of the resource in question.", + "description": "name is the name of the resource in question.", "type": "string" } }, @@ -2906,19 +3773,19 @@ ], "type": "object" }, - "v2beta2.CrossVersionObjectReference": { + "v2.CrossVersionObjectReference": { "description": "CrossVersionObjectReference contains enough information to let you identify the referred resource.", "properties": { "apiVersion": { - "description": "API version of the referent", + "description": "apiVersion is the API version of the referent", "type": "string" }, "kind": { - "description": "Kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds\"", + "description": "kind is the kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", "type": "string" }, "name": { - "description": "Name of the referent; More info: http://kubernetes.io/docs/user-guide/identifiers#names", + "description": "name is the name of the referent; More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", "type": "string" } }, @@ -2928,15 +3795,15 @@ ], "type": "object" }, - "v2beta2.ExternalMetricSource": { + "v2.ExternalMetricSource": { "description": "ExternalMetricSource indicates how to scale on a metric not associated with any Kubernetes object (for example length of queue in cloud messaging service, or QPS from loadbalancer running outside of cluster).", "properties": { "metric": { - "$ref": "#/definitions/v2beta2.MetricIdentifier", + "$ref": "#/definitions/v2.MetricIdentifier", "description": "metric identifies the target metric by name and selector" }, "target": { - "$ref": "#/definitions/v2beta2.MetricTarget", + "$ref": "#/definitions/v2.MetricTarget", "description": "target specifies the target value for the given metric" } }, @@ -2946,15 +3813,15 @@ ], "type": "object" }, - "v2beta2.ExternalMetricStatus": { + "v2.ExternalMetricStatus": { "description": "ExternalMetricStatus indicates the current value of a global metric not associated with any Kubernetes object.", "properties": { "current": { - "$ref": "#/definitions/v2beta2.MetricValueStatus", + "$ref": "#/definitions/v2.MetricValueStatus", "description": "current contains the current value for the given metric" }, "metric": { - "$ref": "#/definitions/v2beta2.MetricIdentifier", + "$ref": "#/definitions/v2.MetricIdentifier", "description": "metric identifies the target metric by name and selector" } }, @@ -2964,20 +3831,20 @@ ], "type": "object" }, - "v2beta2.HPAScalingPolicy": { + "v2.HPAScalingPolicy": { "description": "HPAScalingPolicy is a single policy which must hold true for a specified past interval.", "properties": { "periodSeconds": { - "description": "PeriodSeconds specifies the window of time for which the policy should hold true. PeriodSeconds must be greater than zero and less than or equal to 1800 (30 min).", + "description": "periodSeconds specifies the window of time for which the policy should hold true. PeriodSeconds must be greater than zero and less than or equal to 1800 (30 min).", "format": "int32", "type": "integer" }, "type": { - "description": "Type is used to specify the scaling policy.", + "description": "type is used to specify the scaling policy.", "type": "string" }, "value": { - "description": "Value contains the amount of change which is permitted by the policy. It must be greater than zero", + "description": "value contains the amount of change which is permitted by the policy. It must be greater than zero", "format": "int32", "type": "integer" } @@ -2989,29 +3856,34 @@ ], "type": "object" }, - "v2beta2.HPAScalingRules": { - "description": "HPAScalingRules configures the scaling behavior for one direction. These Rules are applied after calculating DesiredReplicas from metrics for the HPA. They can limit the scaling velocity by specifying scaling policies. They can prevent flapping by specifying the stabilization window, so that the number of replicas is not set instantly, instead, the safest value from the stabilization window is chosen.", + "v2.HPAScalingRules": { + "description": "HPAScalingRules configures the scaling behavior for one direction via scaling Policy Rules and a configurable metric tolerance.\n\nScaling Policy Rules are applied after calculating DesiredReplicas from metrics for the HPA. They can limit the scaling velocity by specifying scaling policies. They can prevent flapping by specifying the stabilization window, so that the number of replicas is not set instantly, instead, the safest value from the stabilization window is chosen.\n\nThe tolerance is applied to the metric values and prevents scaling too eagerly for small metric variations. (Note that setting a tolerance requires enabling the alpha HPAConfigurableTolerance feature gate.)", "properties": { "policies": { - "description": "policies is a list of potential scaling polices which can be used during scaling. At least one policy must be specified, otherwise the HPAScalingRules will be discarded as invalid", + "description": "policies is a list of potential scaling polices which can be used during scaling. If not set, use the default values: - For scale up: allow doubling the number of pods, or an absolute change of 4 pods in a 15s window. - For scale down: allow all pods to be removed in a 15s window.", "items": { - "$ref": "#/definitions/v2beta2.HPAScalingPolicy" + "$ref": "#/definitions/v2.HPAScalingPolicy" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "selectPolicy": { - "description": "selectPolicy is used to specify which policy should be used. If not set, the default value MaxPolicySelect is used.", + "description": "selectPolicy is used to specify which policy should be used. If not set, the default value Max is used.", "type": "string" }, "stabilizationWindowSeconds": { - "description": "StabilizationWindowSeconds is the number of seconds for which past recommendations should be considered while scaling up or scaling down. StabilizationWindowSeconds must be greater than or equal to zero and less than or equal to 3600 (one hour). If not set, use the default values: - For scale up: 0 (i.e. no stabilization is done). - For scale down: 300 (i.e. the stabilization window is 300 seconds long).", + "description": "stabilizationWindowSeconds is the number of seconds for which past recommendations should be considered while scaling up or scaling down. StabilizationWindowSeconds must be greater than or equal to zero and less than or equal to 3600 (one hour). If not set, use the default values: - For scale up: 0 (i.e. no stabilization is done). - For scale down: 300 (i.e. the stabilization window is 300 seconds long).", "format": "int32", "type": "integer" + }, + "tolerance": { + "$ref": "#/definitions/resource.Quantity", + "description": "tolerance is the tolerance on the ratio between the current and desired metric value under which no updates are made to the desired number of replicas (e.g. 0.01 for 1%). Must be greater than or equal to zero. If not set, the default cluster-wide tolerance is applied (by default 10%).\n\nFor example, if autoscaling is configured with a memory consumption target of 100Mi, and scale-down and scale-up tolerances of 5% and 1% respectively, scaling will be triggered when the actual consumption falls below 95Mi or exceeds 101Mi.\n\nThis is an alpha field and requires enabling the HPAConfigurableTolerance feature gate." } }, "type": "object" }, - "v2beta2.HorizontalPodAutoscaler": { + "v2.HorizontalPodAutoscaler": { "description": "HorizontalPodAutoscaler is the configuration for a horizontal pod autoscaler, which automatically manages the replica count of any resource implementing the scale subresource based on the metrics specified.", "properties": { "apiVersion": { @@ -3027,11 +3899,11 @@ "description": "metadata is the standard object metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" }, "spec": { - "$ref": "#/definitions/v2beta2.HorizontalPodAutoscalerSpec", + "$ref": "#/definitions/v2.HorizontalPodAutoscalerSpec", "description": "spec is the specification for the behaviour of the autoscaler. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status." }, "status": { - "$ref": "#/definitions/v2beta2.HorizontalPodAutoscalerStatus", + "$ref": "#/definitions/v2.HorizontalPodAutoscalerStatus", "description": "status is the current information about the autoscaler." } }, @@ -3040,25 +3912,25 @@ { "group": "autoscaling", "kind": "HorizontalPodAutoscaler", - "version": "v2beta2" + "version": "v2" } ] }, - "v2beta2.HorizontalPodAutoscalerBehavior": { + "v2.HorizontalPodAutoscalerBehavior": { "description": "HorizontalPodAutoscalerBehavior configures the scaling behavior of the target in both Up and Down directions (scaleUp and scaleDown fields respectively).", "properties": { "scaleDown": { - "$ref": "#/definitions/v2beta2.HPAScalingRules", + "$ref": "#/definitions/v2.HPAScalingRules", "description": "scaleDown is scaling policy for scaling Down. If not set, the default value is to allow to scale down to minReplicas pods, with a 300 second stabilization window (i.e., the highest recommendation for the last 300sec is used)." }, "scaleUp": { - "$ref": "#/definitions/v2beta2.HPAScalingRules", + "$ref": "#/definitions/v2.HPAScalingRules", "description": "scaleUp is scaling policy for scaling Up. If not set, the default value is the higher of:\n * increase no more than 4 pods per 60 seconds\n * double the number of pods per 60 seconds\nNo stabilization is used." } }, "type": "object" }, - "v2beta2.HorizontalPodAutoscalerCondition": { + "v2.HorizontalPodAutoscalerCondition": { "description": "HorizontalPodAutoscalerCondition describes the state of a HorizontalPodAutoscaler at a certain point.", "properties": { "lastTransitionTime": { @@ -3089,7 +3961,7 @@ ], "type": "object" }, - "v2beta2.HorizontalPodAutoscalerList": { + "v2.HorizontalPodAutoscalerList": { "description": "HorizontalPodAutoscalerList is a list of horizontal pod autoscaler objects.", "properties": { "apiVersion": { @@ -3099,7 +3971,7 @@ "items": { "description": "items is the list of horizontal pod autoscaler objects.", "items": { - "$ref": "#/definitions/v2beta2.HorizontalPodAutoscaler" + "$ref": "#/definitions/v2.HorizontalPodAutoscaler" }, "type": "array" }, @@ -3120,15 +3992,15 @@ { "group": "autoscaling", "kind": "HorizontalPodAutoscalerList", - "version": "v2beta2" + "version": "v2" } ] }, - "v2beta2.HorizontalPodAutoscalerSpec": { + "v2.HorizontalPodAutoscalerSpec": { "description": "HorizontalPodAutoscalerSpec describes the desired functionality of the HorizontalPodAutoscaler.", "properties": { "behavior": { - "$ref": "#/definitions/v2beta2.HorizontalPodAutoscalerBehavior", + "$ref": "#/definitions/v2.HorizontalPodAutoscalerBehavior", "description": "behavior configures the scaling behavior of the target in both Up and Down directions (scaleUp and scaleDown fields respectively). If not set, the default HPAScalingRules for scale up and scale down are used." }, "maxReplicas": { @@ -3139,9 +4011,10 @@ "metrics": { "description": "metrics contains the specifications for which to use to calculate the desired replica count (the maximum replica count across all metrics will be used). The desired replica count is calculated multiplying the ratio between the target value and the current value by the current number of pods. Ergo, metrics used must decrease as the pod count is increased, and vice-versa. See the individual metric source types for more information about how each type of metric must respond. If not set, the default metric will be set to 80% average CPU utilization.", "items": { - "$ref": "#/definitions/v2beta2.MetricSpec" + "$ref": "#/definitions/v2.MetricSpec" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "minReplicas": { "description": "minReplicas is the lower limit for the number of replicas to which the autoscaler can scale down. It defaults to 1 pod. minReplicas is allowed to be 0 if the alpha feature gate HPAScaleToZero is enabled and at least one Object or External metric is configured. Scaling is active as long as at least one metric value is available.", @@ -3149,7 +4022,7 @@ "type": "integer" }, "scaleTargetRef": { - "$ref": "#/definitions/v2beta2.CrossVersionObjectReference", + "$ref": "#/definitions/v2.CrossVersionObjectReference", "description": "scaleTargetRef points to the target resource to scale, and is used to the pods for which metrics should be collected, as well as to actually change the replica count." } }, @@ -3159,22 +4032,29 @@ ], "type": "object" }, - "v2beta2.HorizontalPodAutoscalerStatus": { + "v2.HorizontalPodAutoscalerStatus": { "description": "HorizontalPodAutoscalerStatus describes the current status of a horizontal pod autoscaler.", "properties": { "conditions": { "description": "conditions is the set of conditions required for this autoscaler to scale its target, and indicates whether or not those conditions are met.", "items": { - "$ref": "#/definitions/v2beta2.HorizontalPodAutoscalerCondition" + "$ref": "#/definitions/v2.HorizontalPodAutoscalerCondition" }, - "type": "array" + "type": "array", + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" }, "currentMetrics": { "description": "currentMetrics is the last read state of the metrics used by this autoscaler.", "items": { - "$ref": "#/definitions/v2beta2.MetricStatus" + "$ref": "#/definitions/v2.MetricStatus" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "currentReplicas": { "description": "currentReplicas is current number of replicas of pods managed by this autoscaler, as last seen by the autoscaler.", @@ -3198,12 +4078,11 @@ } }, "required": [ - "currentReplicas", "desiredReplicas" ], "type": "object" }, - "v2beta2.MetricIdentifier": { + "v2.MetricIdentifier": { "description": "MetricIdentifier defines the name and optionally selector for a metric", "properties": { "name": { @@ -3220,31 +4099,31 @@ ], "type": "object" }, - "v2beta2.MetricSpec": { + "v2.MetricSpec": { "description": "MetricSpec specifies how to scale based on a single metric (only `type` and one other matching field should be set at once).", "properties": { "containerResource": { - "$ref": "#/definitions/v2beta2.ContainerResourceMetricSource", - "description": "container resource refers to a resource metric (such as those specified in requests and limits) known to Kubernetes describing a single container in each pod of the current scale target (e.g. CPU or memory). Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the \"pods\" source. This is an alpha feature and can be enabled by the HPAContainerMetrics feature flag." + "$ref": "#/definitions/v2.ContainerResourceMetricSource", + "description": "containerResource refers to a resource metric (such as those specified in requests and limits) known to Kubernetes describing a single container in each pod of the current scale target (e.g. CPU or memory). Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the \"pods\" source." }, "external": { - "$ref": "#/definitions/v2beta2.ExternalMetricSource", + "$ref": "#/definitions/v2.ExternalMetricSource", "description": "external refers to a global metric that is not associated with any Kubernetes object. It allows autoscaling based on information coming from components running outside of cluster (for example length of queue in cloud messaging service, or QPS from loadbalancer running outside of cluster)." }, "object": { - "$ref": "#/definitions/v2beta2.ObjectMetricSource", + "$ref": "#/definitions/v2.ObjectMetricSource", "description": "object refers to a metric describing a single kubernetes object (for example, hits-per-second on an Ingress object)." }, "pods": { - "$ref": "#/definitions/v2beta2.PodsMetricSource", + "$ref": "#/definitions/v2.PodsMetricSource", "description": "pods refers to a metric describing each pod in the current scale target (for example, transactions-processed-per-second). The values will be averaged together before being compared to the target value." }, "resource": { - "$ref": "#/definitions/v2beta2.ResourceMetricSource", + "$ref": "#/definitions/v2.ResourceMetricSource", "description": "resource refers to a resource metric (such as those specified in requests and limits) known to Kubernetes describing each pod in the current scale target (e.g. CPU or memory). Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the \"pods\" source." }, "type": { - "description": "type is the type of metric source. It should be one of \"ContainerResource\", \"External\", \"Object\", \"Pods\" or \"Resource\", each mapping to a matching field in the object. Note: \"ContainerResource\" type is available on when the feature-gate HPAContainerMetrics is enabled", + "description": "type is the type of metric source. It should be one of \"ContainerResource\", \"External\", \"Object\", \"Pods\" or \"Resource\", each mapping to a matching field in the object.", "type": "string" } }, @@ -3253,31 +4132,31 @@ ], "type": "object" }, - "v2beta2.MetricStatus": { + "v2.MetricStatus": { "description": "MetricStatus describes the last-read state of a single metric.", "properties": { "containerResource": { - "$ref": "#/definitions/v2beta2.ContainerResourceMetricStatus", + "$ref": "#/definitions/v2.ContainerResourceMetricStatus", "description": "container resource refers to a resource metric (such as those specified in requests and limits) known to Kubernetes describing a single container in each pod in the current scale target (e.g. CPU or memory). Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the \"pods\" source." }, "external": { - "$ref": "#/definitions/v2beta2.ExternalMetricStatus", + "$ref": "#/definitions/v2.ExternalMetricStatus", "description": "external refers to a global metric that is not associated with any Kubernetes object. It allows autoscaling based on information coming from components running outside of cluster (for example length of queue in cloud messaging service, or QPS from loadbalancer running outside of cluster)." }, "object": { - "$ref": "#/definitions/v2beta2.ObjectMetricStatus", + "$ref": "#/definitions/v2.ObjectMetricStatus", "description": "object refers to a metric describing a single kubernetes object (for example, hits-per-second on an Ingress object)." }, "pods": { - "$ref": "#/definitions/v2beta2.PodsMetricStatus", + "$ref": "#/definitions/v2.PodsMetricStatus", "description": "pods refers to a metric describing each pod in the current scale target (for example, transactions-processed-per-second). The values will be averaged together before being compared to the target value." }, "resource": { - "$ref": "#/definitions/v2beta2.ResourceMetricStatus", + "$ref": "#/definitions/v2.ResourceMetricStatus", "description": "resource refers to a resource metric (such as those specified in requests and limits) known to Kubernetes describing each pod in the current scale target (e.g. CPU or memory). Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the \"pods\" source." }, "type": { - "description": "type is the type of metric source. It will be one of \"ContainerResource\", \"External\", \"Object\", \"Pods\" or \"Resource\", each corresponds to a matching field in the object. Note: \"ContainerResource\" type is available on when the feature-gate HPAContainerMetrics is enabled", + "description": "type is the type of metric source. It will be one of \"ContainerResource\", \"External\", \"Object\", \"Pods\" or \"Resource\", each corresponds to a matching field in the object.", "type": "string" } }, @@ -3286,7 +4165,7 @@ ], "type": "object" }, - "v2beta2.MetricTarget": { + "v2.MetricTarget": { "description": "MetricTarget defines the target value, average value, or average utilization of a specific metric", "properties": { "averageUtilization": { @@ -3312,7 +4191,7 @@ ], "type": "object" }, - "v2beta2.MetricValueStatus": { + "v2.MetricValueStatus": { "description": "MetricValueStatus holds the current value for a metric", "properties": { "averageUtilization": { @@ -3331,18 +4210,19 @@ }, "type": "object" }, - "v2beta2.ObjectMetricSource": { + "v2.ObjectMetricSource": { "description": "ObjectMetricSource indicates how to scale on a metric describing a kubernetes object (for example, hits-per-second on an Ingress object).", "properties": { "describedObject": { - "$ref": "#/definitions/v2beta2.CrossVersionObjectReference" + "$ref": "#/definitions/v2.CrossVersionObjectReference", + "description": "describedObject specifies the descriptions of a object,such as kind,name apiVersion" }, "metric": { - "$ref": "#/definitions/v2beta2.MetricIdentifier", + "$ref": "#/definitions/v2.MetricIdentifier", "description": "metric identifies the target metric by name and selector" }, "target": { - "$ref": "#/definitions/v2beta2.MetricTarget", + "$ref": "#/definitions/v2.MetricTarget", "description": "target specifies the target value for the given metric" } }, @@ -3353,18 +4233,19 @@ ], "type": "object" }, - "v2beta2.ObjectMetricStatus": { + "v2.ObjectMetricStatus": { "description": "ObjectMetricStatus indicates the current value of a metric describing a kubernetes object (for example, hits-per-second on an Ingress object).", "properties": { "current": { - "$ref": "#/definitions/v2beta2.MetricValueStatus", + "$ref": "#/definitions/v2.MetricValueStatus", "description": "current contains the current value for the given metric" }, "describedObject": { - "$ref": "#/definitions/v2beta2.CrossVersionObjectReference" + "$ref": "#/definitions/v2.CrossVersionObjectReference", + "description": "DescribedObject specifies the descriptions of a object,such as kind,name apiVersion" }, "metric": { - "$ref": "#/definitions/v2beta2.MetricIdentifier", + "$ref": "#/definitions/v2.MetricIdentifier", "description": "metric identifies the target metric by name and selector" } }, @@ -3375,15 +4256,15 @@ ], "type": "object" }, - "v2beta2.PodsMetricSource": { + "v2.PodsMetricSource": { "description": "PodsMetricSource indicates how to scale on a metric describing each pod in the current scale target (for example, transactions-processed-per-second). The values will be averaged together before being compared to the target value.", "properties": { "metric": { - "$ref": "#/definitions/v2beta2.MetricIdentifier", + "$ref": "#/definitions/v2.MetricIdentifier", "description": "metric identifies the target metric by name and selector" }, "target": { - "$ref": "#/definitions/v2beta2.MetricTarget", + "$ref": "#/definitions/v2.MetricTarget", "description": "target specifies the target value for the given metric" } }, @@ -3393,15 +4274,15 @@ ], "type": "object" }, - "v2beta2.PodsMetricStatus": { + "v2.PodsMetricStatus": { "description": "PodsMetricStatus indicates the current value of a metric describing each pod in the current scale target (for example, transactions-processed-per-second).", "properties": { "current": { - "$ref": "#/definitions/v2beta2.MetricValueStatus", + "$ref": "#/definitions/v2.MetricValueStatus", "description": "current contains the current value for the given metric" }, "metric": { - "$ref": "#/definitions/v2beta2.MetricIdentifier", + "$ref": "#/definitions/v2.MetricIdentifier", "description": "metric identifies the target metric by name and selector" } }, @@ -3411,7 +4292,7 @@ ], "type": "object" }, - "v2beta2.ResourceMetricSource": { + "v2.ResourceMetricSource": { "description": "ResourceMetricSource indicates how to scale on a resource metric known to Kubernetes, as specified in requests and limits, describing each pod in the current scale target (e.g. CPU or memory). The values will be averaged together before being compared to the target. Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the \"pods\" source. Only one \"target\" type should be set.", "properties": { "name": { @@ -3419,7 +4300,7 @@ "type": "string" }, "target": { - "$ref": "#/definitions/v2beta2.MetricTarget", + "$ref": "#/definitions/v2.MetricTarget", "description": "target specifies the target value for the given metric" } }, @@ -3429,15 +4310,15 @@ ], "type": "object" }, - "v2beta2.ResourceMetricStatus": { + "v2.ResourceMetricStatus": { "description": "ResourceMetricStatus indicates the current value of a resource metric known to Kubernetes, as specified in requests and limits, describing each pod in the current scale target (e.g. CPU or memory). Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the \"pods\" source.", "properties": { "current": { - "$ref": "#/definitions/v2beta2.MetricValueStatus", + "$ref": "#/definitions/v2.MetricValueStatus", "description": "current contains the current value for the given metric" }, "name": { - "description": "Name is the name of the resource in question.", + "description": "name is the name of the resource in question.", "type": "string" } }, @@ -3519,7 +4400,7 @@ "description": "CronJobSpec describes how the job execution will look like and when it will actually run.", "properties": { "concurrencyPolicy": { - "description": "Specifies how to treat concurrent executions of a Job. Valid values are: - \"Allow\" (default): allows CronJobs to run concurrently; - \"Forbid\": forbids concurrent runs, skipping next run if previous run hasn't finished yet; - \"Replace\": cancels currently running job and replaces it with a new one\n\n", + "description": "Specifies how to treat concurrent executions of a Job. Valid values are:\n\n- \"Allow\" (default): allows CronJobs to run concurrently; - \"Forbid\": forbids concurrent runs, skipping next run if previous run hasn't finished yet; - \"Replace\": cancels currently running job and replaces it with a new one", "type": "string" }, "failedJobsHistoryLimit": { @@ -3550,7 +4431,7 @@ "type": "boolean" }, "timeZone": { - "description": "The time zone name for the given schedule, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. If not specified, this will default to the time zone of the kube-controller-manager process. The set of valid time zone names and the time zone offset is loaded from the system-wide time zone database by the API server during CronJob validation and the controller manager during execution. If no system-wide time zone database can be found a bundled version of the database is used instead. If the time zone name becomes invalid during the lifetime of a CronJob or due to a change in host configuration, the controller will stop creating new new Jobs and will create a system event with the reason UnknownTimeZone. More information can be found in https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#time-zones This is beta field and must be enabled via the `CronJobTimeZone` feature gate.", + "description": "The time zone name for the given schedule, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. If not specified, this will default to the time zone of the kube-controller-manager process. The set of valid time zone names and the time zone offset is loaded from the system-wide time zone database by the API server during CronJob validation and the controller manager during execution. If no system-wide time zone database can be found a bundled version of the database is used instead. If the time zone name becomes invalid during the lifetime of a CronJob or due to a change in host configuration, the controller will stop creating new new Jobs and will create a system event with the reason UnknownTimeZone. More information can be found in https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#time-zones", "type": "string" } }, @@ -3697,23 +4578,37 @@ "type": "integer" }, "backoffLimit": { - "description": "Specifies the number of retries before marking this job failed. Defaults to 6", + "description": "Specifies the number of retries before marking this job failed. Defaults to 6, unless backoffLimitPerIndex (only Indexed Job) is specified. When backoffLimitPerIndex is specified, backoffLimit defaults to 2147483647.", + "format": "int32", + "type": "integer" + }, + "backoffLimitPerIndex": { + "description": "Specifies the limit for the number of retries within an index before marking this index as failed. When enabled the number of failures per index is kept in the pod's batch.kubernetes.io/job-index-failure-count annotation. It can only be set when Job's completionMode=Indexed, and the Pod's restart policy is Never. The field is immutable.", "format": "int32", "type": "integer" }, "completionMode": { - "description": "CompletionMode specifies how Pod completions are tracked. It can be `NonIndexed` (default) or `Indexed`.\n\n`NonIndexed` means that the Job is considered complete when there have been .spec.completions successfully completed Pods. Each Pod completion is homologous to each other.\n\n`Indexed` means that the Pods of a Job get an associated completion index from 0 to (.spec.completions - 1), available in the annotation batch.kubernetes.io/job-completion-index. The Job is considered complete when there is one successfully completed Pod for each index. When value is `Indexed`, .spec.completions must be specified and `.spec.parallelism` must be less than or equal to 10^5. In addition, The Pod name takes the form `$(job-name)-$(index)-$(random-string)`, the Pod hostname takes the form `$(job-name)-$(index)`.\n\nMore completion modes can be added in the future. If the Job controller observes a mode that it doesn't recognize, which is possible during upgrades due to version skew, the controller skips updates for the Job.", + "description": "completionMode specifies how Pod completions are tracked. It can be `NonIndexed` (default) or `Indexed`.\n\n`NonIndexed` means that the Job is considered complete when there have been .spec.completions successfully completed Pods. Each Pod completion is homologous to each other.\n\n`Indexed` means that the Pods of a Job get an associated completion index from 0 to (.spec.completions - 1), available in the annotation batch.kubernetes.io/job-completion-index. The Job is considered complete when there is one successfully completed Pod for each index. When value is `Indexed`, .spec.completions must be specified and `.spec.parallelism` must be less than or equal to 10^5. In addition, The Pod name takes the form `$(job-name)-$(index)-$(random-string)`, the Pod hostname takes the form `$(job-name)-$(index)`.\n\nMore completion modes can be added in the future. If the Job controller observes a mode that it doesn't recognize, which is possible during upgrades due to version skew, the controller skips updates for the Job.", "type": "string" }, "completions": { - "description": "Specifies the desired number of successfully finished pods the job should be run with. Setting to nil means that the success of any pod signals the success of all pods, and allows parallelism to have any positive value. Setting to 1 means that parallelism is limited to 1 and the success of that pod signals the success of the job. More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/", + "description": "Specifies the desired number of successfully finished pods the job should be run with. Setting to null means that the success of any pod signals the success of all pods, and allows parallelism to have any positive value. Setting to 1 means that parallelism is limited to 1 and the success of that pod signals the success of the job. More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/", "format": "int32", "type": "integer" }, + "managedBy": { + "description": "ManagedBy field indicates the controller that manages a Job. The k8s Job controller reconciles jobs which don't have this field at all or the field value is the reserved string `kubernetes.io/job-controller`, but skips reconciling Jobs with a custom value for this field. The value must be a valid domain-prefixed path (e.g. acme.io/foo) - all characters before the first \"/\" must be a valid subdomain as defined by RFC 1123. All characters trailing the first \"/\" must be valid HTTP Path characters as defined by RFC 3986. The value cannot exceed 63 characters. This field is immutable.\n\nThis field is beta-level. The job controller accepts setting the field when the feature gate JobManagedBy is enabled (enabled by default).", + "type": "string" + }, "manualSelector": { "description": "manualSelector controls generation of pod labels and pod selectors. Leave `manualSelector` unset unless you are certain what you are doing. When false or unset, the system pick labels unique to this job and appends those labels to the pod template. When true, the user is responsible for picking unique labels and specifying the selector. Failure to pick a unique label may cause this and other jobs to not function correctly. However, You may see `manualSelector=true` in jobs that were created with the old `extensions/v1beta1` API. More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#specifying-your-own-pod-selector", "type": "boolean" }, + "maxFailedIndexes": { + "description": "Specifies the maximal number of failed indexes before marking the Job as failed, when backoffLimitPerIndex is set. Once the number of failed indexes exceeds this number the entire Job is marked as Failed and its execution is terminated. When left as null the job continues execution of all of its indexes and is marked with the `Complete` Job condition. It can only be specified when backoffLimitPerIndex is set. It can be null or up to completions. It is required and must be less than or equal to 10^4 when is completions greater than 10^5.", + "format": "int32", + "type": "integer" + }, "parallelism": { "description": "Specifies the maximum desired number of pods the job should run at any given time. The actual number of pods running in steady state will be less than this number when ((.spec.completions - .status.successful) < .spec.parallelism), i.e. when the work left to do is less than max parallelism. More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/", "format": "int32", @@ -3721,19 +4616,27 @@ }, "podFailurePolicy": { "$ref": "#/definitions/v1.PodFailurePolicy", - "description": "Specifies the policy of handling failed pods. In particular, it allows to specify the set of actions and conditions which need to be satisfied to take the associated action. If empty, the default behaviour applies - the counter of failed pods, represented by the jobs's .status.failed field, is incremented and it is checked against the backoffLimit. This field cannot be used in combination with restartPolicy=OnFailure.\n\nThis field is alpha-level. To use this field, you must enable the `JobPodFailurePolicy` feature gate (disabled by default)." + "description": "Specifies the policy of handling failed pods. In particular, it allows to specify the set of actions and conditions which need to be satisfied to take the associated action. If empty, the default behaviour applies - the counter of failed pods, represented by the jobs's .status.failed field, is incremented and it is checked against the backoffLimit. This field cannot be used in combination with restartPolicy=OnFailure." + }, + "podReplacementPolicy": { + "description": "podReplacementPolicy specifies when to create replacement Pods. Possible values are: - TerminatingOrFailed means that we recreate pods\n when they are terminating (has a metadata.deletionTimestamp) or failed.\n- Failed means to wait until a previously created Pod is fully terminated (has phase\n Failed or Succeeded) before creating a replacement Pod.\n\nWhen using podFailurePolicy, Failed is the the only allowed value. TerminatingOrFailed and Failed are allowed values when podFailurePolicy is not in use.", + "type": "string" }, "selector": { "$ref": "#/definitions/v1.LabelSelector", "description": "A label query over pods that should match the pod count. Normally, the system sets this field for you. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors" }, + "successPolicy": { + "$ref": "#/definitions/v1.SuccessPolicy", + "description": "successPolicy specifies the policy when the Job can be declared as succeeded. If empty, the default behavior applies - the Job is declared as succeeded only when the number of succeeded pods equals to the completions. When the field is specified, it must be immutable and works only for the Indexed Jobs. Once the Job meets the SuccessPolicy, the lingering pods are terminated." + }, "suspend": { - "description": "Suspend specifies whether the Job controller should create Pods or not. If a Job is created with suspend set to true, no Pods are created by the Job controller. If a Job is suspended after creation (i.e. the flag goes from false to true), the Job controller will delete all active Pods associated with this Job. Users must design their workload to gracefully handle this. Suspending a Job will reset the StartTime field of the Job, effectively resetting the ActiveDeadlineSeconds timer too. Defaults to false.", + "description": "suspend specifies whether the Job controller should create Pods or not. If a Job is created with suspend set to true, no Pods are created by the Job controller. If a Job is suspended after creation (i.e. the flag goes from false to true), the Job controller will delete all active Pods associated with this Job. Users must design their workload to gracefully handle this. Suspending a Job will reset the StartTime field of the Job, effectively resetting the ActiveDeadlineSeconds timer too. Defaults to false.", "type": "boolean" }, "template": { "$ref": "#/definitions/v1.PodTemplateSpec", - "description": "Describes the pod that will be created when executing a job. More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/" + "description": "Describes the pod that will be created when executing a job. The only allowed template.spec.restartPolicy values are \"Never\" or \"OnFailure\". More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/" }, "ttlSecondsAfterFinished": { "description": "ttlSecondsAfterFinished limits the lifetime of a Job that has finished execution (either Complete or Failed). If this field is set, ttlSecondsAfterFinished after the Job finishes, it is eligible to be automatically deleted. When the Job is being deleted, its lifecycle guarantees (e.g. finalizers) will be honored. If this field is unset, the Job won't be automatically deleted. If this field is set to zero, the Job becomes eligible to be deleted immediately after it finishes.", @@ -3750,21 +4653,21 @@ "description": "JobStatus represents the current state of a Job.", "properties": { "active": { - "description": "The number of pending and running pods.", + "description": "The number of pending and running pods which are not terminating (without a deletionTimestamp). The value is zero for finished jobs.", "format": "int32", "type": "integer" }, "completedIndexes": { - "description": "CompletedIndexes holds the completed indexes when .spec.completionMode = \"Indexed\" in a text format. The indexes are represented as decimal integers separated by commas. The numbers are listed in increasing order. Three or more consecutive numbers are compressed and represented by the first and last element of the series, separated by a hyphen. For example, if the completed indexes are 1, 3, 4, 5 and 7, they are represented as \"1,3-5,7\".", + "description": "completedIndexes holds the completed indexes when .spec.completionMode = \"Indexed\" in a text format. The indexes are represented as decimal integers separated by commas. The numbers are listed in increasing order. Three or more consecutive numbers are compressed and represented by the first and last element of the series, separated by a hyphen. For example, if the completed indexes are 1, 3, 4, 5 and 7, they are represented as \"1,3-5,7\".", "type": "string" }, "completionTime": { - "description": "Represents time when the job was completed. It is not guaranteed to be set in happens-before order across separate operations. It is represented in RFC3339 form and is in UTC. The completion time is only set when the job finishes successfully.", + "description": "Represents time when the job was completed. It is not guaranteed to be set in happens-before order across separate operations. It is represented in RFC3339 form and is in UTC. The completion time is set when the job finishes successfully, and only then. The value cannot be updated or removed. The value indicates the same or later point in time as the startTime field.", "format": "date-time", "type": "string" }, "conditions": { - "description": "The latest available observations of an object's current state. When a Job fails, one of the conditions will have type \"Failed\" and status true. When a Job is suspended, one of the conditions will have type \"Suspended\" and status true; when the Job is resumed, the status of this condition will become false. When a Job is completed, one of the conditions will have type \"Complete\" and status true. More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/", + "description": "The latest available observations of an object's current state. When a Job fails, one of the conditions will have type \"Failed\" and status true. When a Job is suspended, one of the conditions will have type \"Suspended\" and status true; when the Job is resumed, the status of this condition will become false. When a Job is completed, one of the conditions will have type \"Complete\" and status true.\n\nA job is considered finished when it is in a terminal condition, either \"Complete\" or \"Failed\". A Job cannot have both the \"Complete\" and \"Failed\" conditions. Additionally, it cannot be in the \"Complete\" and \"FailureTarget\" conditions. The \"Complete\", \"Failed\" and \"FailureTarget\" conditions cannot be disabled.\n\nMore info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/", "items": { "$ref": "#/definitions/v1.JobCondition" }, @@ -3774,28 +4677,37 @@ "x-kubernetes-patch-strategy": "merge" }, "failed": { - "description": "The number of pods which reached phase Failed.", + "description": "The number of pods which reached phase Failed. The value increases monotonically.", "format": "int32", "type": "integer" }, + "failedIndexes": { + "description": "FailedIndexes holds the failed indexes when spec.backoffLimitPerIndex is set. The indexes are represented in the text format analogous as for the `completedIndexes` field, ie. they are kept as decimal integers separated by commas. The numbers are listed in increasing order. Three or more consecutive numbers are compressed and represented by the first and last element of the series, separated by a hyphen. For example, if the failed indexes are 1, 3, 4, 5 and 7, they are represented as \"1,3-5,7\". The set of failed indexes cannot overlap with the set of completed indexes.", + "type": "string" + }, "ready": { - "description": "The number of pods which have a Ready condition.\n\nThis field is beta-level. The job controller populates the field when the feature gate JobReadyPods is enabled (enabled by default).", + "description": "The number of active pods which have a Ready condition and are not terminating (without a deletionTimestamp).", "format": "int32", "type": "integer" }, "startTime": { - "description": "Represents time when the job controller started processing a job. When a Job is created in the suspended state, this field is not set until the first time it is resumed. This field is reset every time a Job is resumed from suspension. It is represented in RFC3339 form and is in UTC.", + "description": "Represents time when the job controller started processing a job. When a Job is created in the suspended state, this field is not set until the first time it is resumed. This field is reset every time a Job is resumed from suspension. It is represented in RFC3339 form and is in UTC.\n\nOnce set, the field can only be removed when the job is suspended. The field cannot be modified while the job is unsuspended or finished.", "format": "date-time", "type": "string" }, "succeeded": { - "description": "The number of pods which reached phase Succeeded.", + "description": "The number of pods which reached phase Succeeded. The value increases monotonically for a given spec. However, it may decrease in reaction to scale down of elastic indexed jobs.", + "format": "int32", + "type": "integer" + }, + "terminating": { + "description": "The number of pods which are terminating (in phase Pending or Running and have a deletionTimestamp).\n\nThis field is beta-level. The job controller populates the field when the feature gate JobPodReplacementPolicy is enabled (enabled by default).", "format": "int32", "type": "integer" }, "uncountedTerminatedPods": { "$ref": "#/definitions/v1.UncountedTerminatedPods", - "description": "UncountedTerminatedPods holds the UIDs of Pods that have terminated but the job controller hasn't yet accounted for in the status counters.\n\nThe job controller creates pods with a finalizer. When a pod terminates (succeeded or failed), the controller does three steps to account for it in the job status: (1) Add the pod UID to the arrays in this field. (2) Remove the pod finalizer. (3) Remove the pod UID from the arrays while increasing the corresponding\n counter.\n\nThis field is beta-level. The job controller only makes use of this field when the feature gate JobTrackingWithFinalizers is enabled (enabled by default). Old jobs might not be tracked using this field, in which case the field remains null." + "description": "uncountedTerminatedPods holds the UIDs of Pods that have terminated but the job controller hasn't yet accounted for in the status counters.\n\nThe job controller creates pods with a finalizer. When a pod terminates (succeeded or failed), the controller does three steps to account for it in the job status:\n\n1. Add the pod UID to the arrays in this field. 2. Remove the pod finalizer. 3. Remove the pod UID from the arrays while increasing the corresponding\n counter.\n\nOld jobs might not be tracked using this field, in which case the field remains null. The structure is empty for finished jobs." } }, "type": "object" @@ -3839,7 +4751,7 @@ "type": "string" }, "operator": { - "description": "Represents the relationship between the container exit code(s) and the specified values. Containers completed with success (exit code 0) are excluded from the requirement check. Possible values are: - In: the requirement is satisfied if at least one container exit code\n (might be multiple if there are multiple containers not restricted\n by the 'containerName' field) is in the set of specified values.\n- NotIn: the requirement is satisfied if at least one container exit code\n (might be multiple if there are multiple containers not restricted\n by the 'containerName' field) is not in the set of specified values.\nAdditional values are considered to be added in the future. Clients should react to an unknown operator by assuming the requirement is not satisfied.\n\n", + "description": "Represents the relationship between the container exit code(s) and the specified values. Containers completed with success (exit code 0) are excluded from the requirement check. Possible values are:\n\n- In: the requirement is satisfied if at least one container exit code\n (might be multiple if there are multiple containers not restricted\n by the 'containerName' field) is in the set of specified values.\n- NotIn: the requirement is satisfied if at least one container exit code\n (might be multiple if there are multiple containers not restricted\n by the 'containerName' field) is not in the set of specified values.\nAdditional values are considered to be added in the future. Clients should react to an unknown operator by assuming the requirement is not satisfied.", "type": "string" }, "values": { @@ -3877,10 +4789,10 @@ "type": "object" }, "v1.PodFailurePolicyRule": { - "description": "PodFailurePolicyRule describes how a pod failure is handled when the requirements are met. One of OnExitCodes and onPodConditions, but not both, can be used in each rule.", + "description": "PodFailurePolicyRule describes how a pod failure is handled when the requirements are met. One of onExitCodes and onPodConditions, but not both, can be used in each rule.", "properties": { "action": { - "description": "Specifies the action taken on a pod failure when the requirements are satisfied. Possible values are: - FailJob: indicates that the pod's job is marked as Failed and all\n running pods are terminated.\n- Ignore: indicates that the counter towards the .backoffLimit is not\n incremented and a replacement pod is created.\n- Count: indicates that the pod is handled in the default way - the\n counter towards the .backoffLimit is incremented.\nAdditional values are considered to be added in the future. Clients should react to an unknown action by skipping the rule.\n\n", + "description": "Specifies the action taken on a pod failure when the requirements are satisfied. Possible values are:\n\n- FailJob: indicates that the pod's job is marked as Failed and all\n running pods are terminated.\n- FailIndex: indicates that the pod's index is marked as Failed and will\n not be restarted.\n- Ignore: indicates that the counter towards the .backoffLimit is not\n incremented and a replacement pod is created.\n- Count: indicates that the pod is handled in the default way - the\n counter towards the .backoffLimit is incremented.\nAdditional values are considered to be added in the future. Clients should react to an unknown action by skipping the rule.", "type": "string" }, "onExitCodes": { @@ -3897,16 +4809,47 @@ } }, "required": [ - "action", - "onPodConditions" + "action" + ], + "type": "object" + }, + "v1.SuccessPolicy": { + "description": "SuccessPolicy describes when a Job can be declared as succeeded based on the success of some indexes.", + "properties": { + "rules": { + "description": "rules represents the list of alternative rules for the declaring the Jobs as successful before `.status.succeeded >= .spec.completions`. Once any of the rules are met, the \"SuccessCriteriaMet\" condition is added, and the lingering pods are removed. The terminal state for such a Job has the \"Complete\" condition. Additionally, these rules are evaluated in order; Once the Job meets one of the rules, other rules are ignored. At most 20 elements are allowed.", + "items": { + "$ref": "#/definitions/v1.SuccessPolicyRule" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + } + }, + "required": [ + "rules" ], "type": "object" }, + "v1.SuccessPolicyRule": { + "description": "SuccessPolicyRule describes rule for declaring a Job as succeeded. Each rule must have at least one of the \"succeededIndexes\" or \"succeededCount\" specified.", + "properties": { + "succeededCount": { + "description": "succeededCount specifies the minimal required size of the actual set of the succeeded indexes for the Job. When succeededCount is used along with succeededIndexes, the check is constrained only to the set of indexes specified by succeededIndexes. For example, given that succeededIndexes is \"1-4\", succeededCount is \"3\", and completed indexes are \"1\", \"3\", and \"5\", the Job isn't declared as succeeded because only \"1\" and \"3\" indexes are considered in that rules. When this field is null, this doesn't default to any value and is never evaluated at any time. When specified it needs to be a positive integer.", + "format": "int32", + "type": "integer" + }, + "succeededIndexes": { + "description": "succeededIndexes specifies the set of indexes which need to be contained in the actual set of the succeeded indexes for the Job. The list of indexes must be within 0 to \".spec.completions-1\" and must not contain duplicates. At least one element is required. The indexes are represented as intervals separated by commas. The intervals can be a decimal integer or a pair of decimal integers separated by a hyphen. The number are listed in represented by the first and last element of the series, separated by a hyphen. For example, if the completed indexes are 1, 3, 4, 5 and 7, they are represented as \"1,3-5,7\". When this field is null, this field doesn't default to any value and is never evaluated at any time.", + "type": "string" + } + }, + "type": "object" + }, "v1.UncountedTerminatedPods": { "description": "UncountedTerminatedPods holds UIDs of Pods that have terminated but haven't been accounted in Job status counters.", "properties": { "failed": { - "description": "Failed holds UIDs of failed Pods.", + "description": "failed holds UIDs of failed Pods.", "items": { "type": "string" }, @@ -3914,7 +4857,7 @@ "x-kubernetes-list-type": "set" }, "succeeded": { - "description": "Succeeded holds UIDs of succeeded Pods.", + "description": "succeeded holds UIDs of succeeded Pods.", "items": { "type": "string" }, @@ -4111,6 +5054,343 @@ }, "type": "object" }, + "v1alpha1.ClusterTrustBundle": { + "description": "ClusterTrustBundle is a cluster-scoped container for X.509 trust anchors (root certificates).\n\nClusterTrustBundle objects are considered to be readable by any authenticated user in the cluster, because they can be mounted by pods using the `clusterTrustBundle` projection. All service accounts have read access to ClusterTrustBundles by default. Users who only have namespace-level access to a cluster can read ClusterTrustBundles by impersonating a serviceaccount that they have access to.\n\nIt can be optionally associated with a particular assigner, in which case it contains one valid set of trust anchors for that signer. Signers may have multiple associated ClusterTrustBundles; each is an independent set of trust anchors for that signer. Admission control is used to enforce that only users with permissions on the signer can create or modify the corresponding bundle.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/v1.ObjectMeta", + "description": "metadata contains the object metadata." + }, + "spec": { + "$ref": "#/definitions/v1alpha1.ClusterTrustBundleSpec", + "description": "spec contains the signer (if any) and trust anchors." + } + }, + "required": [ + "spec" + ], + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "certificates.k8s.io", + "kind": "ClusterTrustBundle", + "version": "v1alpha1" + } + ] + }, + "v1alpha1.ClusterTrustBundleList": { + "description": "ClusterTrustBundleList is a collection of ClusterTrustBundle objects", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "items is a collection of ClusterTrustBundle objects", + "items": { + "$ref": "#/definitions/v1alpha1.ClusterTrustBundle" + }, + "type": "array" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/v1.ListMeta", + "description": "metadata contains the list metadata." + } + }, + "required": [ + "items" + ], + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "certificates.k8s.io", + "kind": "ClusterTrustBundleList", + "version": "v1alpha1" + } + ] + }, + "v1alpha1.ClusterTrustBundleSpec": { + "description": "ClusterTrustBundleSpec contains the signer and trust anchors.", + "properties": { + "signerName": { + "description": "signerName indicates the associated signer, if any.\n\nIn order to create or update a ClusterTrustBundle that sets signerName, you must have the following cluster-scoped permission: group=certificates.k8s.io resource=signers resourceName= verb=attest.\n\nIf signerName is not empty, then the ClusterTrustBundle object must be named with the signer name as a prefix (translating slashes to colons). For example, for the signer name `example.com/foo`, valid ClusterTrustBundle object names include `example.com:foo:abc` and `example.com:foo:v1`.\n\nIf signerName is empty, then the ClusterTrustBundle object's name must not have such a prefix.\n\nList/watch requests for ClusterTrustBundles can filter on this field using a `spec.signerName=NAME` field selector.", + "type": "string" + }, + "trustBundle": { + "description": "trustBundle contains the individual X.509 trust anchors for this bundle, as PEM bundle of PEM-wrapped, DER-formatted X.509 certificates.\n\nThe data must consist only of PEM certificate blocks that parse as valid X.509 certificates. Each certificate must include a basic constraints extension with the CA bit set. The API server will reject objects that contain duplicate certificates, or that use PEM block headers.\n\nUsers of ClusterTrustBundles, including Kubelet, are free to reorder and deduplicate certificate blocks in this file according to their own logic, as well as to drop PEM block headers and inter-block data.", + "type": "string" + } + }, + "required": [ + "trustBundle" + ], + "type": "object" + }, + "v1alpha1.PodCertificateRequest": { + "description": "PodCertificateRequest encodes a pod requesting a certificate from a given signer.\n\nKubelets use this API to implement podCertificate projected volumes", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/v1.ObjectMeta", + "description": "metadata contains the object metadata." + }, + "spec": { + "$ref": "#/definitions/v1alpha1.PodCertificateRequestSpec", + "description": "spec contains the details about the certificate being requested." + }, + "status": { + "$ref": "#/definitions/v1alpha1.PodCertificateRequestStatus", + "description": "status contains the issued certificate, and a standard set of conditions." + } + }, + "required": [ + "spec" + ], + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "certificates.k8s.io", + "kind": "PodCertificateRequest", + "version": "v1alpha1" + } + ] + }, + "v1alpha1.PodCertificateRequestList": { + "description": "PodCertificateRequestList is a collection of PodCertificateRequest objects", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "items is a collection of PodCertificateRequest objects", + "items": { + "$ref": "#/definitions/v1alpha1.PodCertificateRequest" + }, + "type": "array" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/v1.ListMeta", + "description": "metadata contains the list metadata." + } + }, + "required": [ + "items" + ], + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "certificates.k8s.io", + "kind": "PodCertificateRequestList", + "version": "v1alpha1" + } + ] + }, + "v1alpha1.PodCertificateRequestSpec": { + "description": "PodCertificateRequestSpec describes the certificate request. All fields are immutable after creation.", + "properties": { + "maxExpirationSeconds": { + "description": "maxExpirationSeconds is the maximum lifetime permitted for the certificate.\n\nIf omitted, kube-apiserver will set it to 86400(24 hours). kube-apiserver will reject values shorter than 3600 (1 hour). The maximum allowable value is 7862400 (91 days).\n\nThe signer implementation is then free to issue a certificate with any lifetime *shorter* than MaxExpirationSeconds, but no shorter than 3600 seconds (1 hour). This constraint is enforced by kube-apiserver. `kubernetes.io` signers will never issue certificates with a lifetime longer than 24 hours.", + "format": "int32", + "type": "integer" + }, + "nodeName": { + "description": "nodeName is the name of the node the pod is assigned to.", + "type": "string" + }, + "nodeUID": { + "description": "nodeUID is the UID of the node the pod is assigned to.", + "type": "string" + }, + "pkixPublicKey": { + "description": "pkixPublicKey is the PKIX-serialized public key the signer will issue the certificate to.\n\nThe key must be one of RSA3072, RSA4096, ECDSAP256, ECDSAP384, ECDSAP521, or ED25519. Note that this list may be expanded in the future.\n\nSigner implementations do not need to support all key types supported by kube-apiserver and kubelet. If a signer does not support the key type used for a given PodCertificateRequest, it must deny the request by setting a status.conditions entry with a type of \"Denied\" and a reason of \"UnsupportedKeyType\". It may also suggest a key type that it does support in the message field.", + "format": "byte", + "type": "string" + }, + "podName": { + "description": "podName is the name of the pod into which the certificate will be mounted.", + "type": "string" + }, + "podUID": { + "description": "podUID is the UID of the pod into which the certificate will be mounted.", + "type": "string" + }, + "proofOfPossession": { + "description": "proofOfPossession proves that the requesting kubelet holds the private key corresponding to pkixPublicKey.\n\nIt is contructed by signing the ASCII bytes of the pod's UID using `pkixPublicKey`.\n\nkube-apiserver validates the proof of possession during creation of the PodCertificateRequest.\n\nIf the key is an RSA key, then the signature is over the ASCII bytes of the pod UID, using RSASSA-PSS from RFC 8017 (as implemented by the golang function crypto/rsa.SignPSS with nil options).\n\nIf the key is an ECDSA key, then the signature is as described by [SEC 1, Version 2.0](https://www.secg.org/sec1-v2.pdf) (as implemented by the golang library function crypto/ecdsa.SignASN1)\n\nIf the key is an ED25519 key, the the signature is as described by the [ED25519 Specification](https://ed25519.cr.yp.to/) (as implemented by the golang library crypto/ed25519.Sign).", + "format": "byte", + "type": "string" + }, + "serviceAccountName": { + "description": "serviceAccountName is the name of the service account the pod is running as.", + "type": "string" + }, + "serviceAccountUID": { + "description": "serviceAccountUID is the UID of the service account the pod is running as.", + "type": "string" + }, + "signerName": { + "description": "signerName indicates the requested signer.\n\nAll signer names beginning with `kubernetes.io` are reserved for use by the Kubernetes project. There is currently one well-known signer documented by the Kubernetes project, `kubernetes.io/kube-apiserver-client-pod`, which will issue client certificates understood by kube-apiserver. It is currently unimplemented.", + "type": "string" + } + }, + "required": [ + "signerName", + "podName", + "podUID", + "serviceAccountName", + "serviceAccountUID", + "nodeName", + "nodeUID", + "pkixPublicKey", + "proofOfPossession" + ], + "type": "object" + }, + "v1alpha1.PodCertificateRequestStatus": { + "description": "PodCertificateRequestStatus describes the status of the request, and holds the certificate data if the request is issued.", + "properties": { + "beginRefreshAt": { + "description": "beginRefreshAt is the time at which the kubelet should begin trying to refresh the certificate. This field is set via the /status subresource, and must be set at the same time as certificateChain. Once populated, this field is immutable.\n\nThis field is only a hint. Kubelet may start refreshing before or after this time if necessary.", + "format": "date-time", + "type": "string" + }, + "certificateChain": { + "description": "certificateChain is populated with an issued certificate by the signer. This field is set via the /status subresource. Once populated, this field is immutable.\n\nIf the certificate signing request is denied, a condition of type \"Denied\" is added and this field remains empty. If the signer cannot issue the certificate, a condition of type \"Failed\" is added and this field remains empty.\n\nValidation requirements:\n 1. certificateChain must consist of one or more PEM-formatted certificates.\n 2. Each entry must be a valid PEM-wrapped, DER-encoded ASN.1 Certificate as\n described in section 4 of RFC5280.\n\nIf more than one block is present, and the definition of the requested spec.signerName does not indicate otherwise, the first block is the issued certificate, and subsequent blocks should be treated as intermediate certificates and presented in TLS handshakes. When projecting the chain into a pod volume, kubelet will drop any data in-between the PEM blocks, as well as any PEM block headers.", + "type": "string" + }, + "conditions": { + "description": "conditions applied to the request.\n\nThe types \"Issued\", \"Denied\", and \"Failed\" have special handling. At most one of these conditions may be present, and they must have status \"True\".\n\nIf the request is denied with `Reason=UnsupportedKeyType`, the signer may suggest a key type that will work in the message field.", + "items": { + "$ref": "#/definitions/v1.Condition" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" + }, + "notAfter": { + "description": "notAfter is the time at which the certificate expires. The value must be the same as the notAfter value in the leaf certificate in certificateChain. This field is set via the /status subresource. Once populated, it is immutable. The signer must set this field at the same time it sets certificateChain.", + "format": "date-time", + "type": "string" + }, + "notBefore": { + "description": "notBefore is the time at which the certificate becomes valid. The value must be the same as the notBefore value in the leaf certificate in certificateChain. This field is set via the /status subresource. Once populated, it is immutable. The signer must set this field at the same time it sets certificateChain.", + "format": "date-time", + "type": "string" + } + }, + "type": "object" + }, + "v1beta1.ClusterTrustBundle": { + "description": "ClusterTrustBundle is a cluster-scoped container for X.509 trust anchors (root certificates).\n\nClusterTrustBundle objects are considered to be readable by any authenticated user in the cluster, because they can be mounted by pods using the `clusterTrustBundle` projection. All service accounts have read access to ClusterTrustBundles by default. Users who only have namespace-level access to a cluster can read ClusterTrustBundles by impersonating a serviceaccount that they have access to.\n\nIt can be optionally associated with a particular assigner, in which case it contains one valid set of trust anchors for that signer. Signers may have multiple associated ClusterTrustBundles; each is an independent set of trust anchors for that signer. Admission control is used to enforce that only users with permissions on the signer can create or modify the corresponding bundle.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/v1.ObjectMeta", + "description": "metadata contains the object metadata." + }, + "spec": { + "$ref": "#/definitions/v1beta1.ClusterTrustBundleSpec", + "description": "spec contains the signer (if any) and trust anchors." + } + }, + "required": [ + "spec" + ], + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "certificates.k8s.io", + "kind": "ClusterTrustBundle", + "version": "v1beta1" + } + ] + }, + "v1beta1.ClusterTrustBundleList": { + "description": "ClusterTrustBundleList is a collection of ClusterTrustBundle objects", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "items is a collection of ClusterTrustBundle objects", + "items": { + "$ref": "#/definitions/v1beta1.ClusterTrustBundle" + }, + "type": "array" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/v1.ListMeta", + "description": "metadata contains the list metadata." + } + }, + "required": [ + "items" + ], + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "certificates.k8s.io", + "kind": "ClusterTrustBundleList", + "version": "v1beta1" + } + ] + }, + "v1beta1.ClusterTrustBundleSpec": { + "description": "ClusterTrustBundleSpec contains the signer and trust anchors.", + "properties": { + "signerName": { + "description": "signerName indicates the associated signer, if any.\n\nIn order to create or update a ClusterTrustBundle that sets signerName, you must have the following cluster-scoped permission: group=certificates.k8s.io resource=signers resourceName= verb=attest.\n\nIf signerName is not empty, then the ClusterTrustBundle object must be named with the signer name as a prefix (translating slashes to colons). For example, for the signer name `example.com/foo`, valid ClusterTrustBundle object names include `example.com:foo:abc` and `example.com:foo:v1`.\n\nIf signerName is empty, then the ClusterTrustBundle object's name must not have such a prefix.\n\nList/watch requests for ClusterTrustBundles can filter on this field using a `spec.signerName=NAME` field selector.", + "type": "string" + }, + "trustBundle": { + "description": "trustBundle contains the individual X.509 trust anchors for this bundle, as PEM bundle of PEM-wrapped, DER-formatted X.509 certificates.\n\nThe data must consist only of PEM certificate blocks that parse as valid X.509 certificates. Each certificate must include a basic constraints extension with the CA bit set. The API server will reject objects that contain duplicate certificates, or that use PEM block headers.\n\nUsers of ClusterTrustBundles, including Kubelet, are free to reorder and deduplicate certificate blocks in this file according to their own logic, as well as to drop PEM block headers and inter-block data.", + "type": "string" + } + }, + "required": [ + "trustBundle" + ], + "type": "object" + }, "v1.Lease": { "description": "Lease defines a lease concept.", "properties": { @@ -4128,7 +5408,7 @@ }, "spec": { "$ref": "#/definitions/v1.LeaseSpec", - "description": "Specification of the Lease. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" + "description": "spec contains the specification of the Lease. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, "type": "object", @@ -4148,7 +5428,7 @@ "type": "string" }, "items": { - "description": "Items is a list of schema objects.", + "description": "items is a list of schema objects.", "items": { "$ref": "#/definitions/v1.Lease" }, @@ -4184,11 +5464,11 @@ "type": "string" }, "holderIdentity": { - "description": "holderIdentity contains the identity of the holder of a current lease.", + "description": "holderIdentity contains the identity of the holder of a current lease. If Coordinated Leader Election is used, the holder identity must be equal to the elected LeaseCandidate.metadata.name field.", "type": "string" }, "leaseDurationSeconds": { - "description": "leaseDurationSeconds is a duration that candidates for a lease need to wait to force acquire it. This is measure against time of last observed RenewTime.", + "description": "leaseDurationSeconds is a duration that candidates for a lease need to wait to force acquire it. This is measured against the time of last observed renewTime.", "format": "int32", "type": "integer" }, @@ -4197,14 +5477,224 @@ "format": "int32", "type": "integer" }, + "preferredHolder": { + "description": "PreferredHolder signals to a lease holder that the lease has a more optimal holder and should be given up. This field can only be set if Strategy is also set.", + "type": "string" + }, "renewTime": { "description": "renewTime is a time when the current holder of a lease has last updated the lease.", "format": "date-time", "type": "string" + }, + "strategy": { + "description": "Strategy indicates the strategy for picking the leader for coordinated leader election. If the field is not specified, there is no active coordination for this lease. (Alpha) Using this field requires the CoordinatedLeaderElection feature gate to be enabled.", + "type": "string" } }, "type": "object" }, + "v1alpha2.LeaseCandidate": { + "description": "LeaseCandidate defines a candidate for a Lease object. Candidates are created such that coordinated leader election will pick the best leader from the list of candidates.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/v1.ObjectMeta", + "description": "More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + }, + "spec": { + "$ref": "#/definitions/v1alpha2.LeaseCandidateSpec", + "description": "spec contains the specification of the Lease. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" + } + }, + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "coordination.k8s.io", + "kind": "LeaseCandidate", + "version": "v1alpha2" + } + ] + }, + "v1alpha2.LeaseCandidateList": { + "description": "LeaseCandidateList is a list of Lease objects.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "items is a list of schema objects.", + "items": { + "$ref": "#/definitions/v1alpha2.LeaseCandidate" + }, + "type": "array" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/v1.ListMeta", + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + } + }, + "required": [ + "items" + ], + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "coordination.k8s.io", + "kind": "LeaseCandidateList", + "version": "v1alpha2" + } + ] + }, + "v1alpha2.LeaseCandidateSpec": { + "description": "LeaseCandidateSpec is a specification of a Lease.", + "properties": { + "binaryVersion": { + "description": "BinaryVersion is the binary version. It must be in a semver format without leading `v`. This field is required.", + "type": "string" + }, + "emulationVersion": { + "description": "EmulationVersion is the emulation version. It must be in a semver format without leading `v`. EmulationVersion must be less than or equal to BinaryVersion. This field is required when strategy is \"OldestEmulationVersion\"", + "type": "string" + }, + "leaseName": { + "description": "LeaseName is the name of the lease for which this candidate is contending. This field is immutable.", + "type": "string" + }, + "pingTime": { + "description": "PingTime is the last time that the server has requested the LeaseCandidate to renew. It is only done during leader election to check if any LeaseCandidates have become ineligible. When PingTime is updated, the LeaseCandidate will respond by updating RenewTime.", + "format": "date-time", + "type": "string" + }, + "renewTime": { + "description": "RenewTime is the time that the LeaseCandidate was last updated. Any time a Lease needs to do leader election, the PingTime field is updated to signal to the LeaseCandidate that they should update the RenewTime. Old LeaseCandidate objects are also garbage collected if it has been hours since the last renew. The PingTime field is updated regularly to prevent garbage collection for still active LeaseCandidates.", + "format": "date-time", + "type": "string" + }, + "strategy": { + "description": "Strategy is the strategy that coordinated leader election will use for picking the leader. If multiple candidates for the same Lease return different strategies, the strategy provided by the candidate with the latest BinaryVersion will be used. If there is still conflict, this is a user error and coordinated leader election will not operate the Lease until resolved.", + "type": "string" + } + }, + "required": [ + "leaseName", + "binaryVersion", + "strategy" + ], + "type": "object" + }, + "v1beta1.LeaseCandidate": { + "description": "LeaseCandidate defines a candidate for a Lease object. Candidates are created such that coordinated leader election will pick the best leader from the list of candidates.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/v1.ObjectMeta", + "description": "More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + }, + "spec": { + "$ref": "#/definitions/v1beta1.LeaseCandidateSpec", + "description": "spec contains the specification of the Lease. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" + } + }, + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "coordination.k8s.io", + "kind": "LeaseCandidate", + "version": "v1beta1" + } + ] + }, + "v1beta1.LeaseCandidateList": { + "description": "LeaseCandidateList is a list of Lease objects.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "items is a list of schema objects.", + "items": { + "$ref": "#/definitions/v1beta1.LeaseCandidate" + }, + "type": "array" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/v1.ListMeta", + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + } + }, + "required": [ + "items" + ], + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "coordination.k8s.io", + "kind": "LeaseCandidateList", + "version": "v1beta1" + } + ] + }, + "v1beta1.LeaseCandidateSpec": { + "description": "LeaseCandidateSpec is a specification of a Lease.", + "properties": { + "binaryVersion": { + "description": "BinaryVersion is the binary version. It must be in a semver format without leading `v`. This field is required.", + "type": "string" + }, + "emulationVersion": { + "description": "EmulationVersion is the emulation version. It must be in a semver format without leading `v`. EmulationVersion must be less than or equal to BinaryVersion. This field is required when strategy is \"OldestEmulationVersion\"", + "type": "string" + }, + "leaseName": { + "description": "LeaseName is the name of the lease for which this candidate is contending. The limits on this field are the same as on Lease.name. Multiple lease candidates may reference the same Lease.name. This field is immutable.", + "type": "string" + }, + "pingTime": { + "description": "PingTime is the last time that the server has requested the LeaseCandidate to renew. It is only done during leader election to check if any LeaseCandidates have become ineligible. When PingTime is updated, the LeaseCandidate will respond by updating RenewTime.", + "format": "date-time", + "type": "string" + }, + "renewTime": { + "description": "RenewTime is the time that the LeaseCandidate was last updated. Any time a Lease needs to do leader election, the PingTime field is updated to signal to the LeaseCandidate that they should update the RenewTime. Old LeaseCandidate objects are also garbage collected if it has been hours since the last renew. The PingTime field is updated regularly to prevent garbage collection for still active LeaseCandidates.", + "format": "date-time", + "type": "string" + }, + "strategy": { + "description": "Strategy is the strategy that coordinated leader election will use for picking the leader. If multiple candidates for the same Lease return different strategies, the strategy provided by the candidate with the latest BinaryVersion will be used. If there is still conflict, this is a user error and coordinated leader election will not operate the Lease until resolved.", + "type": "string" + } + }, + "required": [ + "leaseName", + "binaryVersion", + "strategy" + ], + "type": "object" + }, "v1.AWSElasticBlockStoreVolumeSource": { "description": "Represents a Persistent Disk resource in AWS.\n\nAn AWS EBS disk must exist before mounting to a container. The disk must also be in the same AWS zone as the kubelet. An AWS EBS disk can only be mounted as read/write once. AWS EBS volumes support ownership management and SELinux relabeling.", "properties": { @@ -4249,6 +5739,31 @@ }, "type": "object" }, + "v1.AppArmorProfile": { + "description": "AppArmorProfile defines a pod or container's AppArmor settings.", + "properties": { + "localhostProfile": { + "description": "localhostProfile indicates a profile loaded on the node that should be used. The profile must be preconfigured on the node to work. Must match the loaded name of the profile. Must be set if and only if type is \"Localhost\".", + "type": "string" + }, + "type": { + "description": "type indicates which kind of AppArmor profile will be applied. Valid options are:\n Localhost - a profile pre-loaded on the node.\n RuntimeDefault - the container runtime's default profile.\n Unconfined - no AppArmor enforcement.", + "type": "string" + } + }, + "required": [ + "type" + ], + "type": "object", + "x-kubernetes-unions": [ + { + "discriminator": "type", + "fields-to-discriminateBy": { + "localhostProfile": "LocalhostProfile" + } + } + ] + }, "v1.AttachedVolume": { "description": "AttachedVolume describes a volume attached to a node", "properties": { @@ -4350,7 +5865,7 @@ "type": "object" }, "v1.Binding": { - "description": "Binding ties one object to another; for example, a pod is bound to a node by a scheduler. Deprecated in 1.7, please use the bindings subresource of pods instead.", + "description": "Binding ties one object to another; for example, a pod is bound to a node by a scheduler.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", @@ -4382,11 +5897,11 @@ ] }, "v1.CSIPersistentVolumeSource": { - "description": "Represents storage that is managed by an external CSI volume driver (Beta feature)", + "description": "Represents storage that is managed by an external CSI volume driver", "properties": { "controllerExpandSecretRef": { "$ref": "#/definitions/v1.SecretReference", - "description": "controllerExpandSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI ControllerExpandVolume call. This is an beta field and requires enabling ExpandCSIVolumes feature gate. This field is optional, and may be empty if no secret is required. If the secret object contains more than one secret, all secrets are passed." + "description": "controllerExpandSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI ControllerExpandVolume call. This field is optional, and may be empty if no secret is required. If the secret object contains more than one secret, all secrets are passed." }, "controllerPublishSecretRef": { "$ref": "#/definitions/v1.SecretReference", @@ -4402,7 +5917,7 @@ }, "nodeExpandSecretRef": { "$ref": "#/definitions/v1.SecretReference", - "description": "nodeExpandSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI NodeExpandVolume call. This is an alpha field and requires enabling CSINodeExpandSecret feature gate. This field is optional, may be omitted if no secret is required. If the secret object contains more than one secret, all secrets are passed." + "description": "nodeExpandSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI NodeExpandVolume call. This field is optional, may be omitted if no secret is required. If the secret object contains more than one secret, all secrets are passed." }, "nodePublishSecretRef": { "$ref": "#/definitions/v1.SecretReference", @@ -4474,14 +5989,16 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "drop": { "description": "Removed capabilities", "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object" @@ -4494,7 +6011,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "path": { "description": "path is Optional: Used as the mounted root, rather than the full Ceph tree, default is /", @@ -4530,7 +6048,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "path": { "description": "path is Optional: Used as the mounted root, rather than the full Ceph tree, default is /", @@ -4619,6 +6138,35 @@ }, "type": "object" }, + "v1.ClusterTrustBundleProjection": { + "description": "ClusterTrustBundleProjection describes how to select a set of ClusterTrustBundle objects and project their contents into the pod filesystem.", + "properties": { + "labelSelector": { + "$ref": "#/definitions/v1.LabelSelector", + "description": "Select all ClusterTrustBundles that match this label selector. Only has effect if signerName is set. Mutually-exclusive with name. If unset, interpreted as \"match nothing\". If set but empty, interpreted as \"match everything\"." + }, + "name": { + "description": "Select a single ClusterTrustBundle by object name. Mutually-exclusive with signerName and labelSelector.", + "type": "string" + }, + "optional": { + "description": "If true, don't block pod startup if the referenced ClusterTrustBundle(s) aren't available. If using name, then the named ClusterTrustBundle is allowed not to exist. If using signerName, then the combination of signerName and labelSelector is allowed to match zero ClusterTrustBundles.", + "type": "boolean" + }, + "path": { + "description": "Relative path from the volume root to write the bundle.", + "type": "string" + }, + "signerName": { + "description": "Select all ClusterTrustBundles that match this signer name. Mutually-exclusive with name. The contents of all selected ClusterTrustBundles will be unified and deduplicated.", + "type": "string" + } + }, + "required": [ + "path" + ], + "type": "object" + }, "v1.ComponentCondition": { "description": "Information about the condition of a component.", "properties": { @@ -4658,6 +6206,10 @@ "$ref": "#/definitions/v1.ComponentCondition" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "type", "x-kubernetes-patch-strategy": "merge" }, @@ -4762,7 +6314,7 @@ "description": "ConfigMapEnvSource selects a ConfigMap to populate the environment variables with.\n\nThe contents of the target ConfigMap's Data field will represent the key-value pairs as environment variables.", "properties": { "name": { - "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "description": "Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", "type": "string" }, "optional": { @@ -4780,7 +6332,7 @@ "type": "string" }, "name": { - "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "description": "Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", "type": "string" }, "optional": { @@ -4868,10 +6420,11 @@ "items": { "$ref": "#/definitions/v1.KeyToPath" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "name": { - "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "description": "Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", "type": "string" }, "optional": { @@ -4894,10 +6447,11 @@ "items": { "$ref": "#/definitions/v1.KeyToPath" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "name": { - "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "description": "Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", "type": "string" }, "optional": { @@ -4915,14 +6469,16 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "command": { "description": "Entrypoint array. Not executed within a shell. The container image's ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. \"$$(VAR_NAME)\" will produce the string literal \"$(VAR_NAME)\". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell", "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "env": { "description": "List of environment variables to set in the container. Cannot be updated.", @@ -4930,22 +6486,27 @@ "$ref": "#/definitions/v1.EnvVar" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "name", "x-kubernetes-patch-strategy": "merge" }, "envFrom": { - "description": "List of sources to populate environment variables in the container. The keys defined within a source must be a C_IDENTIFIER. All invalid keys will be reported as an event when the container is starting. When a key exists in multiple sources, the value associated with the last source will take precedence. Values defined by an Env with a duplicate key will take precedence. Cannot be updated.", + "description": "List of sources to populate environment variables in the container. The keys defined within a source may consist of any printable ASCII characters except '='. When a key exists in multiple sources, the value associated with the last source will take precedence. Values defined by an Env with a duplicate key will take precedence. Cannot be updated.", "items": { "$ref": "#/definitions/v1.EnvFromSource" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "image": { "description": "Container image name. More info: https://kubernetes.io/docs/concepts/containers/images This field is optional to allow higher level config management to default or override container images in workload controllers like Deployments and StatefulSets.", "type": "string" }, "imagePullPolicy": { - "description": "Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images\n\n", + "description": "Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images", "type": "string" }, "lifecycle": { @@ -4978,10 +6539,30 @@ "$ref": "#/definitions/v1.Probe", "description": "Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes" }, + "resizePolicy": { + "description": "Resources resize policy for the container.", + "items": { + "$ref": "#/definitions/v1.ContainerResizePolicy" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, "resources": { "$ref": "#/definitions/v1.ResourceRequirements", "description": "Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/" }, + "restartPolicy": { + "description": "RestartPolicy defines the restart behavior of individual containers in a pod. This overrides the pod-level restart policy. When this field is not specified, the restart behavior is defined by the Pod's restart policy and the container type. Additionally, setting the RestartPolicy as \"Always\" for the init container will have the following effect: this init container will be continually restarted on exit until all regular containers have terminated. Once all regular containers have completed, all init containers with restartPolicy \"Always\" will be shut down. This lifecycle differs from normal init containers and is often referred to as a \"sidecar\" container. Although this init container still starts in the init container sequence, it does not wait for the container to complete before proceeding to the next init container. Instead, the next init container starts immediately after this init container is started, or after any startupProbe has successfully completed.", + "type": "string" + }, + "restartPolicyRules": { + "description": "Represents a list of rules to be checked to determine if the container should be restarted on exit. The rules are evaluated in order. Once a rule matches a container exit condition, the remaining rules are ignored. If no rule matches the container exit condition, the Container-level restart policy determines the whether the container is restarted or not. Constraints on the rules: - At most 20 rules are allowed. - Rules can have the same action. - Identical rules are not forbidden in validations. When rules are specified, container MUST set RestartPolicy explicitly even it if matches the Pod's RestartPolicy.", + "items": { + "$ref": "#/definitions/v1.ContainerRestartRule" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, "securityContext": { "$ref": "#/definitions/v1.SecurityContext", "description": "SecurityContext defines the security options the container should be run with. If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/" @@ -5003,7 +6584,7 @@ "type": "string" }, "terminationMessagePolicy": { - "description": "Indicate how the termination message should be populated. File will use the contents of terminationMessagePath to populate the container status message on both success and failure. FallbackToLogsOnError will use the last chunk of container log output if the termination message file is empty and the container exited with an error. The log output is limited to 2048 bytes or 80 lines, whichever is smaller. Defaults to File. Cannot be updated.\n\n", + "description": "Indicate how the termination message should be populated. File will use the contents of terminationMessagePath to populate the container status message on both success and failure. FallbackToLogsOnError will use the last chunk of container log output if the termination message file is empty and the container exited with an error. The log output is limited to 2048 bytes or 80 lines, whichever is smaller. Defaults to File. Cannot be updated.", "type": "string" }, "tty": { @@ -5016,6 +6597,10 @@ "$ref": "#/definitions/v1.VolumeDevice" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "devicePath" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "devicePath", "x-kubernetes-patch-strategy": "merge" }, @@ -5025,6 +6610,10 @@ "$ref": "#/definitions/v1.VolumeMount" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "mountPath" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "mountPath", "x-kubernetes-patch-strategy": "merge" }, @@ -5038,6 +6627,29 @@ ], "type": "object" }, + "v1.ContainerExtendedResourceRequest": { + "description": "ContainerExtendedResourceRequest has the mapping of container name, extended resource name to the device request name.", + "properties": { + "containerName": { + "description": "The name of the container requesting resources.", + "type": "string" + }, + "requestName": { + "description": "The name of the request in the special ResourceClaim which corresponds to the extended resource.", + "type": "string" + }, + "resourceName": { + "description": "The name of the extended resource in that container which gets backed by DRA.", + "type": "string" + } + }, + "required": [ + "containerName", + "resourceName", + "requestName" + ], + "type": "object" + }, "v1.ContainerImage": { "description": "Describe a container image", "properties": { @@ -5046,7 +6658,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "sizeBytes": { "description": "The size of the image in bytes.", @@ -5078,7 +6691,7 @@ "type": "string" }, "protocol": { - "description": "Protocol for port. Must be UDP, TCP, or SCTP. Defaults to \"TCP\".\n\n", + "description": "Protocol for port. Must be UDP, TCP, or SCTP. Defaults to \"TCP\".", "type": "string" } }, @@ -5087,6 +6700,63 @@ ], "type": "object" }, + "v1.ContainerResizePolicy": { + "description": "ContainerResizePolicy represents resource resize policy for the container.", + "properties": { + "resourceName": { + "description": "Name of the resource to which this resource resize policy applies. Supported values: cpu, memory.", + "type": "string" + }, + "restartPolicy": { + "description": "Restart policy to apply when specified resource is resized. If not specified, it defaults to NotRequired.", + "type": "string" + } + }, + "required": [ + "resourceName", + "restartPolicy" + ], + "type": "object" + }, + "v1.ContainerRestartRule": { + "description": "ContainerRestartRule describes how a container exit is handled.", + "properties": { + "action": { + "description": "Specifies the action taken on a container exit if the requirements are satisfied. The only possible value is \"Restart\" to restart the container.", + "type": "string" + }, + "exitCodes": { + "$ref": "#/definitions/v1.ContainerRestartRuleOnExitCodes", + "description": "Represents the exit codes to check on container exits." + } + }, + "required": [ + "action" + ], + "type": "object" + }, + "v1.ContainerRestartRuleOnExitCodes": { + "description": "ContainerRestartRuleOnExitCodes describes the condition for handling an exited container based on its exit codes.", + "properties": { + "operator": { + "description": "Represents the relationship between the container exit code(s) and the specified values. Possible values are: - In: the requirement is satisfied if the container exit code is in the\n set of specified values.\n- NotIn: the requirement is satisfied if the container exit code is\n not in the set of specified values.", + "type": "string" + }, + "values": { + "description": "Specifies the set of values to check for container exit codes. At most 255 elements are allowed.", + "items": { + "format": "int32", + "type": "integer" + }, + "type": "array", + "x-kubernetes-list-type": "set" + } + }, + "required": [ + "operator" + ], + "type": "object" + }, "v1.ContainerState": { "description": "ContainerState holds a possible state of container. Only one of its members may be specified. If none of them is specified, the default one is ContainerStateWaiting.", "properties": { @@ -5174,42 +6844,87 @@ "v1.ContainerStatus": { "description": "ContainerStatus contains details for the current status of this container.", "properties": { + "allocatedResources": { + "additionalProperties": { + "$ref": "#/definitions/resource.Quantity" + }, + "description": "AllocatedResources represents the compute resources allocated for this container by the node. Kubelet sets this value to Container.Resources.Requests upon successful pod admission and after successfully admitting desired pod resize.", + "type": "object" + }, + "allocatedResourcesStatus": { + "description": "AllocatedResourcesStatus represents the status of various resources allocated for this Pod.", + "items": { + "$ref": "#/definitions/v1.ResourceStatus" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + }, "containerID": { - "description": "Container's ID in the format '://'.", + "description": "ContainerID is the ID of the container in the format '://'. Where type is a container runtime identifier, returned from Version call of CRI API (for example \"containerd\").", "type": "string" }, "image": { - "description": "The image the container is running. More info: https://kubernetes.io/docs/concepts/containers/images.", + "description": "Image is the name of container image that the container is running. The container image may not match the image used in the PodSpec, as it may have been resolved by the runtime. More info: https://kubernetes.io/docs/concepts/containers/images.", "type": "string" }, "imageID": { - "description": "ImageID of the container's image.", + "description": "ImageID is the image ID of the container's image. The image ID may not match the image ID of the image used in the PodSpec, as it may have been resolved by the runtime.", "type": "string" }, "lastState": { "$ref": "#/definitions/v1.ContainerState", - "description": "Details about the container's last termination condition." + "description": "LastTerminationState holds the last termination state of the container to help debug container crashes and restarts. This field is not populated if the container is still running and RestartCount is 0." }, "name": { - "description": "This must be a DNS_LABEL. Each container in a pod must have a unique name. Cannot be updated.", + "description": "Name is a DNS_LABEL representing the unique name of the container. Each container in a pod must have a unique name across all container types. Cannot be updated.", "type": "string" }, "ready": { - "description": "Specifies whether the container has passed its readiness probe.", + "description": "Ready specifies whether the container is currently passing its readiness check. The value will change as readiness probes keep executing. If no readiness probes are specified, this field defaults to true once the container is fully started (see Started field).\n\nThe value is typically used to determine whether a container is ready to accept traffic.", "type": "boolean" }, + "resources": { + "$ref": "#/definitions/v1.ResourceRequirements", + "description": "Resources represents the compute resource requests and limits that have been successfully enacted on the running container after it has been started or has been successfully resized." + }, "restartCount": { - "description": "The number of times the container has been restarted.", + "description": "RestartCount holds the number of times the container has been restarted. Kubelet makes an effort to always increment the value, but there are cases when the state may be lost due to node restarts and then the value may be reset to 0. The value is never negative.", "format": "int32", "type": "integer" }, "started": { - "description": "Specifies whether the container has passed its startup probe. Initialized as false, becomes true after startupProbe is considered successful. Resets to false when the container is restarted, or if kubelet loses state temporarily. Is always true when no startupProbe is defined.", + "description": "Started indicates whether the container has finished its postStart lifecycle hook and passed its startup probe. Initialized as false, becomes true after startupProbe is considered successful. Resets to false when the container is restarted, or if kubelet loses state temporarily. In both cases, startup probes will run again. Is always true when no startupProbe is defined and container is running and has passed the postStart lifecycle hook. The null value must be treated the same as false.", "type": "boolean" }, "state": { "$ref": "#/definitions/v1.ContainerState", - "description": "Details about the container's current condition." + "description": "State holds details about the container's current condition." + }, + "stopSignal": { + "description": "StopSignal reports the effective stop signal for this container", + "type": "string" + }, + "user": { + "$ref": "#/definitions/v1.ContainerUser", + "description": "User represents user identity information initially attached to the first process of the container" + }, + "volumeMounts": { + "description": "Status of volume mounts.", + "items": { + "$ref": "#/definitions/v1.VolumeMountStatus" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "mountPath" + ], + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "mountPath", + "x-kubernetes-patch-strategy": "merge" } }, "required": [ @@ -5221,6 +6936,16 @@ ], "type": "object" }, + "v1.ContainerUser": { + "description": "ContainerUser represents user identity information", + "properties": { + "linux": { + "$ref": "#/definitions/v1.LinuxContainerUser", + "description": "Linux holds user identity information initially attached to the first process of the containers in Linux. Note that the actual running identity can be changed if the process has enough privilege to do so." + } + }, + "type": "object" + }, "v1.DaemonEndpoint": { "description": "DaemonEndpoint contains information about a single Daemon endpoint.", "properties": { @@ -5243,7 +6968,8 @@ "items": { "$ref": "#/definitions/v1.DownwardAPIVolumeFile" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object" @@ -5253,7 +6979,7 @@ "properties": { "fieldRef": { "$ref": "#/definitions/v1.ObjectFieldSelector", - "description": "Required: Selects a field of the pod: only annotations, labels, name and namespace are supported." + "description": "Required: Selects a field of the pod: only annotations, labels, name, namespace and uid are supported." }, "mode": { "description": "Optional: mode bits used to set permissions on this file, must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.", @@ -5287,7 +7013,8 @@ "items": { "$ref": "#/definitions/v1.DownwardAPIVolumeFile" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object" @@ -5301,20 +7028,20 @@ }, "sizeLimit": { "$ref": "#/definitions/resource.Quantity", - "description": "sizeLimit is the total amount of local storage required for this EmptyDir volume. The size limit is also applicable for memory medium. The maximum usage on memory medium EmptyDir would be the minimum value between the SizeLimit specified here and the sum of memory limits of all containers in a pod. The default is nil which means that the limit is undefined. More info: http://kubernetes.io/docs/user-guide/volumes#emptydir" + "description": "sizeLimit is the total amount of local storage required for this EmptyDir volume. The size limit is also applicable for memory medium. The maximum usage on memory medium EmptyDir would be the minimum value between the SizeLimit specified here and the sum of memory limits of all containers in a pod. The default is nil which means that the limit is undefined. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir" } }, "type": "object" }, "v1.EndpointAddress": { - "description": "EndpointAddress is a tuple that describes single IP address.", + "description": "EndpointAddress is a tuple that describes single IP address. Deprecated: This API is deprecated in v1.33+.", "properties": { "hostname": { "description": "The Hostname of this endpoint", "type": "string" }, "ip": { - "description": "The IP of this endpoint. May not be loopback (127.0.0.0/8), link-local (169.254.0.0/16), or link-local multicast ((224.0.0.0/24). IPv6 is also accepted but not fully supported on all platforms. Also, certain kubernetes components, like kube-proxy, are not IPv6 ready.", + "description": "The IP of this endpoint. May not be loopback (127.0.0.0/8 or ::1), link-local (169.254.0.0/16 or fe80::/10), or link-local multicast (224.0.0.0/24 or ff02::/16).", "type": "string" }, "nodeName": { @@ -5333,10 +7060,10 @@ "x-kubernetes-map-type": "atomic" }, "core.v1.EndpointPort": { - "description": "EndpointPort is a tuple that describes a single port.", + "description": "EndpointPort is a tuple that describes a single port. Deprecated: This API is deprecated in v1.33+.", "properties": { "appProtocol": { - "description": "The application protocol for this port. This field follows standard Kubernetes label syntax. Un-prefixed names are reserved for IANA standard service names (as per RFC-6335 and https://www.iana.org/assignments/service-names). Non-standard protocols should use prefixed names such as mycompany.com/my-custom-protocol.", + "description": "The application protocol for this port. This is used as a hint for implementations to offer richer behavior for protocols that they understand. This field follows standard Kubernetes label syntax. Valid values are either:\n\n* Un-prefixed protocol names - reserved for IANA standard service names (as per RFC-6335 and https://www.iana.org/assignments/service-names).\n\n* Kubernetes-defined prefixed names:\n * 'kubernetes.io/h2c' - HTTP/2 prior knowledge over cleartext as described in https://www.rfc-editor.org/rfc/rfc9113.html#name-starting-http-2-with-prior-\n * 'kubernetes.io/ws' - WebSocket over cleartext as described in https://www.rfc-editor.org/rfc/rfc6455\n * 'kubernetes.io/wss' - WebSocket over TLS as described in https://www.rfc-editor.org/rfc/rfc6455\n\n* Other protocols should use implementation-defined prefixed names such as mycompany.com/my-custom-protocol.", "type": "string" }, "name": { @@ -5349,7 +7076,7 @@ "type": "integer" }, "protocol": { - "description": "The IP protocol for this port. Must be UDP, TCP, or SCTP. Default is TCP.\n\n", + "description": "The IP protocol for this port. Must be UDP, TCP, or SCTP. Default is TCP.", "type": "string" } }, @@ -5360,34 +7087,37 @@ "x-kubernetes-map-type": "atomic" }, "v1.EndpointSubset": { - "description": "EndpointSubset is a group of addresses with a common set of ports. The expanded set of endpoints is the Cartesian product of Addresses x Ports. For example, given:\n\n\t{\n\t Addresses: [{\"ip\": \"10.10.1.1\"}, {\"ip\": \"10.10.2.2\"}],\n\t Ports: [{\"name\": \"a\", \"port\": 8675}, {\"name\": \"b\", \"port\": 309}]\n\t}\n\nThe resulting set of endpoints can be viewed as:\n\n\ta: [ 10.10.1.1:8675, 10.10.2.2:8675 ],\n\tb: [ 10.10.1.1:309, 10.10.2.2:309 ]", + "description": "EndpointSubset is a group of addresses with a common set of ports. The expanded set of endpoints is the Cartesian product of Addresses x Ports. For example, given:\n\n\t{\n\t Addresses: [{\"ip\": \"10.10.1.1\"}, {\"ip\": \"10.10.2.2\"}],\n\t Ports: [{\"name\": \"a\", \"port\": 8675}, {\"name\": \"b\", \"port\": 309}]\n\t}\n\nThe resulting set of endpoints can be viewed as:\n\n\ta: [ 10.10.1.1:8675, 10.10.2.2:8675 ],\n\tb: [ 10.10.1.1:309, 10.10.2.2:309 ]\n\nDeprecated: This API is deprecated in v1.33+.", "properties": { "addresses": { "description": "IP addresses which offer the related ports that are marked as ready. These endpoints should be considered safe for load balancers and clients to utilize.", "items": { "$ref": "#/definitions/v1.EndpointAddress" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "notReadyAddresses": { "description": "IP addresses which offer the related ports but are not currently marked as ready because they have not yet finished starting, have recently failed a readiness check, or have recently failed a liveness check.", "items": { "$ref": "#/definitions/v1.EndpointAddress" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "ports": { "description": "Port numbers available on the related IP addresses.", "items": { "$ref": "#/definitions/core.v1.EndpointPort" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object" }, "v1.Endpoints": { - "description": "Endpoints is a collection of endpoints that implement the actual service. Example:\n\n\t Name: \"mysvc\",\n\t Subsets: [\n\t {\n\t Addresses: [{\"ip\": \"10.10.1.1\"}, {\"ip\": \"10.10.2.2\"}],\n\t Ports: [{\"name\": \"a\", \"port\": 8675}, {\"name\": \"b\", \"port\": 309}]\n\t },\n\t {\n\t Addresses: [{\"ip\": \"10.10.3.3\"}],\n\t Ports: [{\"name\": \"a\", \"port\": 93}, {\"name\": \"b\", \"port\": 76}]\n\t },\n\t]", + "description": "Endpoints is a collection of endpoints that implement the actual service. Example:\n\n\t Name: \"mysvc\",\n\t Subsets: [\n\t {\n\t Addresses: [{\"ip\": \"10.10.1.1\"}, {\"ip\": \"10.10.2.2\"}],\n\t Ports: [{\"name\": \"a\", \"port\": 8675}, {\"name\": \"b\", \"port\": 309}]\n\t },\n\t {\n\t Addresses: [{\"ip\": \"10.10.3.3\"}],\n\t Ports: [{\"name\": \"a\", \"port\": 93}, {\"name\": \"b\", \"port\": 76}]\n\t },\n\t]\n\nEndpoints is a legacy API and does not contain information about all Service features. Use discoveryv1.EndpointSlice for complete information about Service endpoints.\n\nDeprecated: This API is deprecated in v1.33+. Use discoveryv1.EndpointSlice.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", @@ -5406,7 +7136,8 @@ "items": { "$ref": "#/definitions/v1.EndpointSubset" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object", @@ -5419,7 +7150,7 @@ ] }, "v1.EndpointsList": { - "description": "EndpointsList is a list of endpoints.", + "description": "EndpointsList is a list of endpoints. Deprecated: This API is deprecated in v1.33+.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", @@ -5454,14 +7185,14 @@ ] }, "v1.EnvFromSource": { - "description": "EnvFromSource represents the source of a set of ConfigMaps", + "description": "EnvFromSource represents the source of a set of ConfigMaps or Secrets", "properties": { "configMapRef": { "$ref": "#/definitions/v1.ConfigMapEnvSource", "description": "The ConfigMap to select from" }, "prefix": { - "description": "An optional identifier to prepend to each key in the ConfigMap. Must be a C_IDENTIFIER.", + "description": "Optional text to prepend to the name of each environment variable. May consist of any printable ASCII characters except '='.", "type": "string" }, "secretRef": { @@ -5475,7 +7206,7 @@ "description": "EnvVar represents an environment variable present in a Container.", "properties": { "name": { - "description": "Name of the environment variable. Must be a C_IDENTIFIER.", + "description": "Name of the environment variable. May consist of any printable ASCII characters except '='.", "type": "string" }, "value": { @@ -5503,6 +7234,10 @@ "$ref": "#/definitions/v1.ObjectFieldSelector", "description": "Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs." }, + "fileKeyRef": { + "$ref": "#/definitions/v1.FileKeySelector", + "description": "FileKeyRef selects a key of the env file. Requires the EnvFiles feature gate to be enabled." + }, "resourceFieldRef": { "$ref": "#/definitions/v1.ResourceFieldSelector", "description": "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported." @@ -5522,14 +7257,16 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "command": { "description": "Entrypoint array. Not executed within a shell. The image's ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. \"$$(VAR_NAME)\" will produce the string literal \"$(VAR_NAME)\". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell", "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "env": { "description": "List of environment variables to set in the container. Cannot be updated.", @@ -5537,22 +7274,27 @@ "$ref": "#/definitions/v1.EnvVar" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "name", "x-kubernetes-patch-strategy": "merge" }, "envFrom": { - "description": "List of sources to populate environment variables in the container. The keys defined within a source must be a C_IDENTIFIER. All invalid keys will be reported as an event when the container is starting. When a key exists in multiple sources, the value associated with the last source will take precedence. Values defined by an Env with a duplicate key will take precedence. Cannot be updated.", + "description": "List of sources to populate environment variables in the container. The keys defined within a source may consist of any printable ASCII characters except '='. When a key exists in multiple sources, the value associated with the last source will take precedence. Values defined by an Env with a duplicate key will take precedence. Cannot be updated.", "items": { "$ref": "#/definitions/v1.EnvFromSource" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "image": { "description": "Container image name. More info: https://kubernetes.io/docs/concepts/containers/images", "type": "string" }, "imagePullPolicy": { - "description": "Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images\n\n", + "description": "Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images", "type": "string" }, "lifecycle": { @@ -5585,10 +7327,30 @@ "$ref": "#/definitions/v1.Probe", "description": "Probes are not allowed for ephemeral containers." }, + "resizePolicy": { + "description": "Resources resize policy for the container.", + "items": { + "$ref": "#/definitions/v1.ContainerResizePolicy" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, "resources": { "$ref": "#/definitions/v1.ResourceRequirements", "description": "Resources are not allowed for ephemeral containers. Ephemeral containers use spare resources already allocated to the pod." }, + "restartPolicy": { + "description": "Restart policy for the container to manage the restart behavior of each container within a pod. You cannot set this field on ephemeral containers.", + "type": "string" + }, + "restartPolicyRules": { + "description": "Represents a list of rules to be checked to determine if the container should be restarted on exit. You cannot set this field on ephemeral containers.", + "items": { + "$ref": "#/definitions/v1.ContainerRestartRule" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, "securityContext": { "$ref": "#/definitions/v1.SecurityContext", "description": "Optional: SecurityContext defines the security options the ephemeral container should be run with. If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext." @@ -5614,7 +7376,7 @@ "type": "string" }, "terminationMessagePolicy": { - "description": "Indicate how the termination message should be populated. File will use the contents of terminationMessagePath to populate the container status message on both success and failure. FallbackToLogsOnError will use the last chunk of container log output if the termination message file is empty and the container exited with an error. The log output is limited to 2048 bytes or 80 lines, whichever is smaller. Defaults to File. Cannot be updated.\n\n", + "description": "Indicate how the termination message should be populated. File will use the contents of terminationMessagePath to populate the container status message on both success and failure. FallbackToLogsOnError will use the last chunk of container log output if the termination message file is empty and the container exited with an error. The log output is limited to 2048 bytes or 80 lines, whichever is smaller. Defaults to File. Cannot be updated.", "type": "string" }, "tty": { @@ -5627,6 +7389,10 @@ "$ref": "#/definitions/v1.VolumeDevice" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "devicePath" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "devicePath", "x-kubernetes-patch-strategy": "merge" }, @@ -5636,6 +7402,10 @@ "$ref": "#/definitions/v1.VolumeMount" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "mountPath" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "mountPath", "x-kubernetes-patch-strategy": "merge" }, @@ -5821,7 +7591,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object" @@ -5847,18 +7618,48 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "wwids": { "description": "wwids Optional: FC volume world wide identifiers (wwids) Either wwids or combination of targetWWNs and lun must be set, but not both simultaneously.", "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object" }, + "v1.FileKeySelector": { + "description": "FileKeySelector selects a key of the env file.", + "properties": { + "key": { + "description": "The key within the env file. An invalid key will prevent the pod from starting. The keys defined within a source may consist of any printable ASCII characters except '='. During Alpha stage of the EnvFiles feature gate, the key size is limited to 128 characters.", + "type": "string" + }, + "optional": { + "description": "Specify whether the file or its key must be defined. If the file or key does not exist, then the env var is not published. If optional is set to true and the specified key does not exist, the environment variable will not be set in the Pod's containers.\n\nIf optional is set to false and the specified key does not exist, an error will be returned during Pod creation.", + "type": "boolean" + }, + "path": { + "description": "The path within the volume from which to select the file. Must be relative and may not contain the '..' path or start with '..'.", + "type": "string" + }, + "volumeName": { + "description": "The name of the volume mount containing the env file.", + "type": "string" + } + }, + "required": [ + "volumeName", + "path", + "key" + ], + "type": "object", + "x-kubernetes-map-type": "atomic" + }, "v1.FlexPersistentVolumeSource": { "description": "FlexPersistentVolumeSource represents a generic persistent volume resource that is provisioned/attached using an exec based plugin.", "properties": { @@ -5964,6 +7765,7 @@ "type": "object" }, "v1.GRPCAction": { + "description": "GRPCAction specifies an action involving a GRPC service.", "properties": { "port": { "description": "Port number of the gRPC service. Number must be in the range 1 to 65535.", @@ -6031,7 +7833,7 @@ "description": "Represents a Glusterfs mount that lasts the lifetime of a pod. Glusterfs volumes do not support ownership management or SELinux relabeling.", "properties": { "endpoints": { - "description": "endpoints is the endpoint name that details Glusterfs topology. More info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod", + "description": "endpoints is the endpoint name that details Glusterfs topology.", "type": "string" }, "path": { @@ -6061,7 +7863,8 @@ "items": { "$ref": "#/definitions/v1.HTTPHeader" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "path": { "description": "Path to access on the HTTP server.", @@ -6072,7 +7875,7 @@ "description": "Name or number of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME." }, "scheme": { - "description": "Scheme to use for connecting to the host. Defaults to HTTP.\n\n", + "description": "Scheme to use for connecting to the host. Defaults to HTTP.", "type": "string" } }, @@ -6085,7 +7888,7 @@ "description": "HTTPHeader describes a custom header to be used in HTTP probes", "properties": { "name": { - "description": "The header field name", + "description": "The header field name. This will be canonicalized upon output, so case-variant names will be understood as the same header.", "type": "string" }, "value": { @@ -6107,13 +7910,30 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "ip": { "description": "IP address of the host file entry.", "type": "string" } }, + "required": [ + "ip" + ], + "type": "object" + }, + "v1.HostIP": { + "description": "HostIP represents a single IP address allocated to the host.", + "properties": { + "ip": { + "description": "IP is the IP address assigned to the host", + "type": "string" + } + }, + "required": [ + "ip" + ], "type": "object" }, "v1.HostPathVolumeSource": { @@ -6170,7 +7990,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "readOnly": { "description": "readOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false.", @@ -6229,7 +8050,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "readOnly": { "description": "readOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false.", @@ -6251,6 +8073,20 @@ ], "type": "object" }, + "v1.ImageVolumeSource": { + "description": "ImageVolumeSource represents a image volume resource.", + "properties": { + "pullPolicy": { + "description": "Policy for pulling OCI objects. Possible values are: Always: the kubelet always attempts to pull the reference. Container creation will fail If the pull fails. Never: the kubelet never pulls the reference and only uses a local image or artifact. Container creation will fail if the reference isn't present. IfNotPresent: the kubelet pulls if the reference isn't already present on disk. Container creation will fail if the reference isn't present and the pull fails. Defaults to Always if :latest tag is specified, or IfNotPresent otherwise.", + "type": "string" + }, + "reference": { + "description": "Required: Image or artifact reference to be used. Behaves in the same way as pod.spec.containers[*].image. Pull secrets will be assembled in the same way as for the container image by looking up node credentials, SA image pull secrets, and pod spec image pull secrets. More info: https://kubernetes.io/docs/concepts/containers/images This field is optional to allow higher level config management to default or override container images in workload controllers like Deployments and StatefulSets.", + "type": "string" + } + }, + "type": "object" + }, "v1.KeyToPath": { "description": "Maps a string key to a path within a volume.", "properties": { @@ -6284,6 +8120,10 @@ "preStop": { "$ref": "#/definitions/v1.LifecycleHandler", "description": "PreStop is called immediately before a container is terminated due to an API request or management event such as liveness/startup probe failure, preemption, resource contention, etc. The handler is not called if the container crashes or exits. The Pod's termination grace period countdown begins before the PreStop hook is executed. Regardless of the outcome of the handler, the container will eventually terminate within the Pod's termination grace period (unless delayed by finalizers). Other management of the container blocks until the hook completes or until the termination grace period is reached. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks" + }, + "stopSignal": { + "description": "StopSignal defines which signal will be sent to a container when it is being stopped. If not specified, the default is defined by the container runtime in use. StopSignal can only be set for Pods with a non-empty .spec.os.name", + "type": "string" } }, "type": "object" @@ -6293,15 +8133,19 @@ "properties": { "exec": { "$ref": "#/definitions/v1.ExecAction", - "description": "Exec specifies the action to take." + "description": "Exec specifies a command to execute in the container." }, "httpGet": { "$ref": "#/definitions/v1.HTTPGetAction", - "description": "HTTPGet specifies the http request to perform." + "description": "HTTPGet specifies an HTTP GET request to perform." + }, + "sleep": { + "$ref": "#/definitions/v1.SleepAction", + "description": "Sleep represents a duration that the container should sleep." }, "tcpSocket": { "$ref": "#/definitions/v1.TCPSocketAction", - "description": "Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept for the backward compatibility. There are no validation of this field and lifecycle hooks will fail in runtime when tcp handler is specified." + "description": "Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept for backward compatibility. There is no validation of this field and lifecycle hooks will fail at runtime when it is specified." } }, "type": "object" @@ -6426,7 +8270,8 @@ "items": { "$ref": "#/definitions/v1.LimitRangeItem" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "required": [ @@ -6434,6 +8279,35 @@ ], "type": "object" }, + "v1.LinuxContainerUser": { + "description": "LinuxContainerUser represents user identity information in Linux containers", + "properties": { + "gid": { + "description": "GID is the primary gid initially attached to the first process in the container", + "format": "int64", + "type": "integer" + }, + "supplementalGroups": { + "description": "SupplementalGroups are the supplemental groups initially attached to the first process in the container", + "items": { + "format": "int64", + "type": "integer" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "uid": { + "description": "UID is the primary uid initially attached to the first process in the container", + "format": "int64", + "type": "integer" + } + }, + "required": [ + "uid", + "gid" + ], + "type": "object" + }, "v1.LoadBalancerIngress": { "description": "LoadBalancerIngress represents the status of a load-balancer ingress point: traffic intended for the service should be sent to an ingress point.", "properties": { @@ -6445,6 +8319,10 @@ "description": "IP is set for load-balancer ingress points that are IP based (typically GCE or OpenStack load-balancers)", "type": "string" }, + "ipMode": { + "description": "IPMode specifies how the load-balancer IP behaves, and may only be specified when the ip field is specified. Setting this to \"VIP\" indicates that traffic is delivered to the node with the destination set to the load-balancer's IP and port. Setting this to \"Proxy\" indicates that traffic is delivered to the node or pod with the destination set to the node's IP and node port or the pod's IP and port. Service implementations may use this information to adjust traffic routing.", + "type": "string" + }, "ports": { "description": "Ports is a list of records of service ports If used, every port defined in the service should have an entry in it", "items": { @@ -6464,7 +8342,8 @@ "items": { "$ref": "#/definitions/v1.LoadBalancerIngress" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object" @@ -6473,7 +8352,7 @@ "description": "LocalObjectReference contains enough information to let you locate the referenced object inside the same namespace.", "properties": { "name": { - "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "description": "Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", "type": "string" } }, @@ -6481,7 +8360,7 @@ "x-kubernetes-map-type": "atomic" }, "v1.LocalVolumeSource": { - "description": "Local represents directly-attached storage with node affinity (Beta feature)", + "description": "Local represents directly-attached storage with node affinity", "properties": { "fsType": { "description": "fsType is the filesystem type to mount. It applies only when the Path is a block device. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". The default value is to auto-select a filesystem if unspecified.", @@ -6497,6 +8376,23 @@ ], "type": "object" }, + "v1.ModifyVolumeStatus": { + "description": "ModifyVolumeStatus represents the status object of ControllerModifyVolume operation", + "properties": { + "status": { + "description": "status is the status of the ControllerModifyVolume operation. It can be in any of following states:\n - Pending\n Pending indicates that the PersistentVolumeClaim cannot be modified due to unmet requirements, such as\n the specified VolumeAttributesClass not existing.\n - InProgress\n InProgress indicates that the volume is being modified.\n - Infeasible\n Infeasible indicates that the request has been rejected as invalid by the CSI driver. To\n\t resolve the error, a valid VolumeAttributesClass needs to be specified.\nNote: New statuses can be added in the future. Consumers should check for unknown statuses and fail appropriately.", + "type": "string" + }, + "targetVolumeAttributesClassName": { + "description": "targetVolumeAttributesClassName is the name of the VolumeAttributesClass the PVC currently being reconciled", + "type": "string" + } + }, + "required": [ + "status" + ], + "type": "object" + }, "v1.NFSVolumeSource": { "description": "Represents an NFS mount that lasts the lifetime of a pod. NFS volumes do not support ownership management or SELinux relabeling.", "properties": { @@ -6556,14 +8452,16 @@ "description": "NamespaceCondition contains details about state of namespace.", "properties": { "lastTransitionTime": { - "description": "Time is a wrapper around time.Time which supports correct marshaling to YAML and JSON. Wrappers are provided for many of the factory methods that the time package offers.", + "description": "Last time the condition transitioned from one status to another.", "format": "date-time", "type": "string" }, "message": { + "description": "Human-readable message indicating details about last transition.", "type": "string" }, "reason": { + "description": "Unique, one-word, CamelCase reason for the condition's last transition.", "type": "string" }, "status": { @@ -6624,7 +8522,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object" @@ -6638,11 +8537,15 @@ "$ref": "#/definitions/v1.NamespaceCondition" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "type", "x-kubernetes-patch-strategy": "merge" }, "phase": { - "description": "Phase is the current lifecycle phase of the namespace. More info: https://kubernetes.io/docs/tasks/administer-cluster/namespaces/\n\n", + "description": "Phase is the current lifecycle phase of the namespace. More info: https://kubernetes.io/docs/tasks/administer-cluster/namespaces/", "type": "string" } }, @@ -6707,7 +8610,8 @@ "items": { "$ref": "#/definitions/v1.PreferredSchedulingTerm" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "requiredDuringSchedulingIgnoredDuringExecution": { "$ref": "#/definitions/v1.NodeSelector", @@ -6794,6 +8698,16 @@ }, "type": "object" }, + "v1.NodeFeatures": { + "description": "NodeFeatures describes the set of features implemented by the CRI implementation. The features contained in the NodeFeatures should depend only on the cri implementation independent of runtime handlers.", + "properties": { + "supplementalGroupsPolicy": { + "description": "SupplementalGroupsPolicy is set to true if the runtime supports SupplementalGroupsPolicy and ContainerUser.", + "type": "boolean" + } + }, + "type": "object" + }, "v1.NodeList": { "description": "NodeList is the whole list of all Nodes which have been registered with master.", "properties": { @@ -6829,6 +8743,34 @@ } ] }, + "v1.NodeRuntimeHandler": { + "description": "NodeRuntimeHandler is a set of runtime handler information.", + "properties": { + "features": { + "$ref": "#/definitions/v1.NodeRuntimeHandlerFeatures", + "description": "Supported features." + }, + "name": { + "description": "Runtime handler name. Empty for the default runtime handler.", + "type": "string" + } + }, + "type": "object" + }, + "v1.NodeRuntimeHandlerFeatures": { + "description": "NodeRuntimeHandlerFeatures is a set of features implemented by the runtime handler.", + "properties": { + "recursiveReadOnlyMounts": { + "description": "RecursiveReadOnlyMounts is set to true if the runtime handler supports RecursiveReadOnlyMounts.", + "type": "boolean" + }, + "userNamespaces": { + "description": "UserNamespaces is set to true if the runtime handler supports UserNamespaces, including for volumes.", + "type": "boolean" + } + }, + "type": "object" + }, "v1.NodeSelector": { "description": "A node selector represents the union of the results of one or more label queries over a set of nodes; that is, it represents the OR of the selectors represented by the node selector terms.", "properties": { @@ -6837,7 +8779,8 @@ "items": { "$ref": "#/definitions/v1.NodeSelectorTerm" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "required": [ @@ -6854,7 +8797,7 @@ "type": "string" }, "operator": { - "description": "Represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt.\n\n", + "description": "Represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt.", "type": "string" }, "values": { @@ -6862,7 +8805,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "required": [ @@ -6879,14 +8823,16 @@ "items": { "$ref": "#/definitions/v1.NodeSelectorRequirement" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "matchFields": { "description": "A list of node selector requirements by node's fields.", "items": { "$ref": "#/definitions/v1.NodeSelectorRequirement" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object", @@ -6897,7 +8843,7 @@ "properties": { "configSource": { "$ref": "#/definitions/v1.NodeConfigSource", - "description": "Deprecated: Previously used to specify the source of the node's configuration for the DynamicKubeletConfig feature. This feature is removed from Kubelets as of 1.24 and will be fully removed in 1.26." + "description": "Deprecated: Previously used to specify the source of the node's configuration for the DynamicKubeletConfig feature. This feature is removed." }, "externalID": { "description": "Deprecated. Not all kubelets will set this field. Remove field after 1.13. see: https://issues.k8s.io/61966", @@ -6913,6 +8859,7 @@ "type": "string" }, "type": "array", + "x-kubernetes-list-type": "set", "x-kubernetes-patch-strategy": "merge" }, "providerID": { @@ -6924,7 +8871,8 @@ "items": { "$ref": "#/definitions/v1.Taint" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "unschedulable": { "description": "Unschedulable controls node schedulability of new pods. By default, node is schedulable. More info: https://kubernetes.io/docs/concepts/nodes/node/#manual-node-administration", @@ -6937,11 +8885,15 @@ "description": "NodeStatus is information about the current status of a node.", "properties": { "addresses": { - "description": "List of addresses reachable to the node. Queried from cloud provider, if available. More info: https://kubernetes.io/docs/concepts/nodes/node/#addresses Note: This field is declared as mergeable, but the merge key is not sufficiently unique, which can cause data corruption when it is merged. Callers should instead use a full-replacement patch. See http://pr.k8s.io/79391 for an example.", + "description": "List of addresses reachable to the node. Queried from cloud provider, if available. More info: https://kubernetes.io/docs/reference/node/node-status/#addresses Note: This field is declared as mergeable, but the merge key is not sufficiently unique, which can cause data corruption when it is merged. Callers should instead use a full-replacement patch. See https://pr.k8s.io/79391 for an example. Consumers should assume that addresses can change during the lifetime of a Node. However, there are some exceptions where this may not be possible, such as Pods that inherit a Node's address in its own status or consumers of the downward API (status.hostIP).", "items": { "$ref": "#/definitions/v1.NodeAddress" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "type", "x-kubernetes-patch-strategy": "merge" }, @@ -6956,15 +8908,19 @@ "additionalProperties": { "$ref": "#/definitions/resource.Quantity" }, - "description": "Capacity represents the total resources of a node. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#capacity", + "description": "Capacity represents the total resources of a node. More info: https://kubernetes.io/docs/reference/node/node-status/#capacity", "type": "object" }, "conditions": { - "description": "Conditions is an array of current observed node conditions. More info: https://kubernetes.io/docs/concepts/nodes/node/#condition", + "description": "Conditions is an array of current observed node conditions. More info: https://kubernetes.io/docs/reference/node/node-status/#condition", "items": { "$ref": "#/definitions/v1.NodeCondition" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "type", "x-kubernetes-patch-strategy": "merge" }, @@ -6976,34 +8932,60 @@ "$ref": "#/definitions/v1.NodeDaemonEndpoints", "description": "Endpoints of daemons running on the Node." }, + "features": { + "$ref": "#/definitions/v1.NodeFeatures", + "description": "Features describes the set of features implemented by the CRI implementation." + }, "images": { "description": "List of container images on this node", "items": { "$ref": "#/definitions/v1.ContainerImage" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "nodeInfo": { "$ref": "#/definitions/v1.NodeSystemInfo", - "description": "Set of ids/uuids to uniquely identify the node. More info: https://kubernetes.io/docs/concepts/nodes/node/#info" + "description": "Set of ids/uuids to uniquely identify the node. More info: https://kubernetes.io/docs/reference/node/node-status/#info" }, "phase": { - "description": "NodePhase is the recently observed lifecycle phase of the node. More info: https://kubernetes.io/docs/concepts/nodes/node/#phase The field is never populated, and now is deprecated.\n\n", + "description": "NodePhase is the recently observed lifecycle phase of the node. More info: https://kubernetes.io/docs/concepts/nodes/node/#phase The field is never populated, and now is deprecated.", "type": "string" }, + "runtimeHandlers": { + "description": "The available runtime handlers.", + "items": { + "$ref": "#/definitions/v1.NodeRuntimeHandler" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, "volumesAttached": { "description": "List of volumes that are attached to the node.", "items": { "$ref": "#/definitions/v1.AttachedVolume" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "volumesInUse": { "description": "List of attachable volumes in use (mounted) by the node.", "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" + } + }, + "type": "object" + }, + "v1.NodeSwapStatus": { + "description": "NodeSwapStatus represents swap memory information.", + "properties": { + "capacity": { + "description": "Total amount of swap memory in bytes.", + "format": "int64", + "type": "integer" } }, "type": "object" @@ -7028,7 +9010,7 @@ "type": "string" }, "kubeProxyVersion": { - "description": "KubeProxy Version reported by the node.", + "description": "Deprecated: KubeProxy Version reported by the node.", "type": "string" }, "kubeletVersion": { @@ -7047,6 +9029,10 @@ "description": "OS Image reported by the node from /etc/os-release (e.g. Debian GNU/Linux 7 (wheezy)).", "type": "string" }, + "swap": { + "$ref": "#/definitions/v1.NodeSwapStatus", + "description": "Swap Info reported by the node." + }, "systemUUID": { "description": "SystemUUID reported by the node. For unique machine identification MachineID is preferred. This field is specific to Red Hat hosts https://access.redhat.com/documentation/en-us/red_hat_subscription_management/1/html/rhsm/uuid", "type": "string" @@ -7186,7 +9172,7 @@ ] }, "v1.PersistentVolumeClaimCondition": { - "description": "PersistentVolumeClaimCondition contails details about state of pvc", + "description": "PersistentVolumeClaimCondition contains details about state of pvc", "properties": { "lastProbeTime": { "description": "lastProbeTime is the time we probed the condition.", @@ -7203,13 +9189,15 @@ "type": "string" }, "reason": { - "description": "reason is a unique, this should be a short, machine understandable string that gives the reason for condition's last transition. If it reports \"ResizeStarted\" that means the underlying persistent volume is being resized.", + "description": "reason is a unique, this should be a short, machine understandable string that gives the reason for condition's last transition. If it reports \"Resizing\" that means the underlying persistent volume is being resized.", "type": "string" }, "status": { + "description": "Status is the status of the condition. Can be True, False, Unknown. More info: https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#:~:text=state%20of%20pvc-,conditions.status,-(string)%2C%20required", "type": "string" }, "type": { + "description": "Type is the type of the condition. More info: https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#:~:text=set%20to%20%27ResizeStarted%27.-,PersistentVolumeClaimCondition,-contains%20details%20about", "type": "string" } }, @@ -7262,18 +9250,19 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "dataSource": { "$ref": "#/definitions/v1.TypedLocalObjectReference", - "description": "dataSource field can be used to specify either: * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot) * An existing PVC (PersistentVolumeClaim) If the provisioner or an external controller can support the specified data source, it will create a new volume based on the contents of the specified data source. If the AnyVolumeDataSource feature gate is enabled, this field will always have the same contents as the DataSourceRef field." + "description": "dataSource field can be used to specify either: * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot) * An existing PVC (PersistentVolumeClaim) If the provisioner or an external controller can support the specified data source, it will create a new volume based on the contents of the specified data source. When the AnyVolumeDataSource feature gate is enabled, dataSource contents will be copied to dataSourceRef, and dataSourceRef contents will be copied to dataSource when dataSourceRef.namespace is not specified. If the namespace is specified, then dataSourceRef will not be copied to dataSource." }, "dataSourceRef": { - "$ref": "#/definitions/v1.TypedLocalObjectReference", - "description": "dataSourceRef specifies the object from which to populate the volume with data, if a non-empty volume is desired. This may be any local object from a non-empty API group (non core object) or a PersistentVolumeClaim object. When this field is specified, volume binding will only succeed if the type of the specified object matches some installed volume populator or dynamic provisioner. This field will replace the functionality of the DataSource field and as such if both fields are non-empty, they must have the same value. For backwards compatibility, both fields (DataSource and DataSourceRef) will be set to the same value automatically if one of them is empty and the other is non-empty. There are two important differences between DataSource and DataSourceRef: * While DataSource only allows two specific types of objects, DataSourceRef\n allows any non-core object, as well as PersistentVolumeClaim objects.\n* While DataSource ignores disallowed values (dropping them), DataSourceRef\n preserves all values, and generates an error if a disallowed value is\n specified.\n(Beta) Using this field requires the AnyVolumeDataSource feature gate to be enabled." + "$ref": "#/definitions/v1.TypedObjectReference", + "description": "dataSourceRef specifies the object from which to populate the volume with data, if a non-empty volume is desired. This may be any object from a non-empty API group (non core object) or a PersistentVolumeClaim object. When this field is specified, volume binding will only succeed if the type of the specified object matches some installed volume populator or dynamic provisioner. This field will replace the functionality of the dataSource field and as such if both fields are non-empty, they must have the same value. For backwards compatibility, when namespace isn't specified in dataSourceRef, both fields (dataSource and dataSourceRef) will be set to the same value automatically if one of them is empty and the other is non-empty. When namespace is specified in dataSourceRef, dataSource isn't set to the same value and must be empty. There are three important differences between dataSource and dataSourceRef: * While dataSource only allows two specific types of objects, dataSourceRef\n allows any non-core object, as well as PersistentVolumeClaim objects.\n* While dataSource ignores disallowed values (dropping them), dataSourceRef\n preserves all values, and generates an error if a disallowed value is\n specified.\n* While dataSource only allows local objects, dataSourceRef allows objects\n in any namespaces.\n(Beta) Using this field requires the AnyVolumeDataSource feature gate to be enabled. (Alpha) Using the namespace field of dataSourceRef requires the CrossNamespaceVolumeDataSource feature gate to be enabled." }, "resources": { - "$ref": "#/definitions/v1.ResourceRequirements", + "$ref": "#/definitions/v1.VolumeResourceRequirements", "description": "resources represents the minimum resources the volume should have. If RecoverVolumeExpansionFailure feature is enabled users are allowed to specify resource requirements that are lower than previous value but must still be higher than capacity recorded in the status field of the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources" }, "selector": { @@ -7284,6 +9273,10 @@ "description": "storageClassName is the name of the StorageClass required by the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1", "type": "string" }, + "volumeAttributesClassName": { + "description": "volumeAttributesClassName may be used to set the VolumeAttributesClass used by this claim. If specified, the CSI driver will create or update the volume with the attributes defined in the corresponding VolumeAttributesClass. This has a different purpose than storageClassName, it can be changed after the claim is created. An empty string or nil value indicates that no VolumeAttributesClass will be applied to the claim. If the claim enters an Infeasible error state, this field can be reset to its previous value (including nil) to cancel the modification. If the resource referred to by volumeAttributesClass does not exist, this PersistentVolumeClaim will be set to a Pending state, as reflected by the modifyVolumeStatus field, until such as a resource exists. More info: https://kubernetes.io/docs/concepts/storage/volume-attributes-classes/", + "type": "string" + }, "volumeMode": { "description": "volumeMode defines what type of volume is required by the claim. Value of Filesystem is implied when not included in claim spec.", "type": "string" @@ -7303,13 +9296,22 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "allocatedResourceStatuses": { + "additionalProperties": { + "type": "string" + }, + "description": "allocatedResourceStatuses stores status of resource being resized for the given PVC. Key names follow standard Kubernetes label syntax. Valid values are either:\n\t* Un-prefixed keys:\n\t\t- storage - the capacity of the volume.\n\t* Custom resources must use implementation-defined prefixed names such as \"example.com/my-custom-resource\"\nApart from above values - keys that are unprefixed or have kubernetes.io prefix are considered reserved and hence may not be used.\n\nClaimResourceStatus can be in any of following states:\n\t- ControllerResizeInProgress:\n\t\tState set when resize controller starts resizing the volume in control-plane.\n\t- ControllerResizeFailed:\n\t\tState set when resize has failed in resize controller with a terminal error.\n\t- NodeResizePending:\n\t\tState set when resize controller has finished resizing the volume but further resizing of\n\t\tvolume is needed on the node.\n\t- NodeResizeInProgress:\n\t\tState set when kubelet starts resizing the volume.\n\t- NodeResizeFailed:\n\t\tState set when resizing has failed in kubelet with a terminal error. Transient errors don't set\n\t\tNodeResizeFailed.\nFor example: if expanding a PVC for more capacity - this field can be one of the following states:\n\t- pvc.status.allocatedResourceStatus['storage'] = \"ControllerResizeInProgress\"\n - pvc.status.allocatedResourceStatus['storage'] = \"ControllerResizeFailed\"\n - pvc.status.allocatedResourceStatus['storage'] = \"NodeResizePending\"\n - pvc.status.allocatedResourceStatus['storage'] = \"NodeResizeInProgress\"\n - pvc.status.allocatedResourceStatus['storage'] = \"NodeResizeFailed\"\nWhen this field is not set, it means that no resize operation is in progress for the given PVC.\n\nA controller that receives PVC update with previously unknown resourceName or ClaimResourceStatus should ignore the update for the purpose it was designed. For example - a controller that only is responsible for resizing capacity of the volume, should ignore PVC updates that change other valid resources associated with PVC.\n\nThis is an alpha field and requires enabling RecoverVolumeExpansionFailure feature.", + "type": "object", + "x-kubernetes-map-type": "granular" }, "allocatedResources": { "additionalProperties": { "$ref": "#/definitions/resource.Quantity" }, - "description": "allocatedResources is the storage resource within AllocatedResources tracks the capacity allocated to a PVC. It may be larger than the actual capacity when a volume expansion operation is requested. For storage quota, the larger value from allocatedResources and PVC.spec.resources is used. If allocatedResources is not set, PVC.spec.resources alone is used for quota calculation. If a volume expansion capacity request is lowered, allocatedResources is only lowered if there are no expansion operations in progress and if the actual volume capacity is equal or lower than the requested capacity. This is an alpha field and requires enabling RecoverVolumeExpansionFailure feature.", + "description": "allocatedResources tracks the resources allocated to a PVC including its capacity. Key names follow standard Kubernetes label syntax. Valid values are either:\n\t* Un-prefixed keys:\n\t\t- storage - the capacity of the volume.\n\t* Custom resources must use implementation-defined prefixed names such as \"example.com/my-custom-resource\"\nApart from above values - keys that are unprefixed or have kubernetes.io prefix are considered reserved and hence may not be used.\n\nCapacity reported here may be larger than the actual capacity when a volume expansion operation is requested. For storage quota, the larger value from allocatedResources and PVC.spec.resources is used. If allocatedResources is not set, PVC.spec.resources alone is used for quota calculation. If a volume expansion capacity request is lowered, allocatedResources is only lowered if there are no expansion operations in progress and if the actual volume capacity is equal or lower than the requested capacity.\n\nA controller that receives PVC update with previously unknown resourceName should ignore the update for the purpose it was designed. For example - a controller that only is responsible for resizing capacity of the volume, should ignore PVC updates that change other valid resources associated with PVC.\n\nThis is an alpha field and requires enabling RecoverVolumeExpansionFailure feature.", "type": "object" }, "capacity": { @@ -7320,20 +9322,28 @@ "type": "object" }, "conditions": { - "description": "conditions is the current Condition of persistent volume claim. If underlying persistent volume is being resized then the Condition will be set to 'ResizeStarted'.", + "description": "conditions is the current Condition of persistent volume claim. If underlying persistent volume is being resized then the Condition will be set to 'Resizing'.", "items": { "$ref": "#/definitions/v1.PersistentVolumeClaimCondition" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "type", "x-kubernetes-patch-strategy": "merge" }, - "phase": { - "description": "phase represents the current phase of PersistentVolumeClaim.\n\n", + "currentVolumeAttributesClassName": { + "description": "currentVolumeAttributesClassName is the current name of the VolumeAttributesClass the PVC is using. When unset, there is no VolumeAttributeClass applied to this PersistentVolumeClaim", "type": "string" }, - "resizeStatus": { - "description": "resizeStatus stores status of resize operation. ResizeStatus is not set by default but when expansion is complete resizeStatus is set to empty string by resize controller or kubelet. This is an alpha field and requires enabling RecoverVolumeExpansionFailure feature.", + "modifyVolumeStatus": { + "$ref": "#/definitions/v1.ModifyVolumeStatus", + "description": "ModifyVolumeStatus represents the status object of ControllerModifyVolume operation. When this is unset, there is no ModifyVolume operation being attempted." + }, + "phase": { + "description": "phase represents the current phase of PersistentVolumeClaim.", "type": "string" } }, @@ -7416,19 +9426,20 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "awsElasticBlockStore": { "$ref": "#/definitions/v1.AWSElasticBlockStoreVolumeSource", - "description": "awsElasticBlockStore represents an AWS Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore" + "description": "awsElasticBlockStore represents an AWS Disk resource that is attached to a kubelet's host machine and then exposed to the pod. Deprecated: AWSElasticBlockStore is deprecated. All operations for the in-tree awsElasticBlockStore type are redirected to the ebs.csi.aws.com CSI driver. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore" }, "azureDisk": { "$ref": "#/definitions/v1.AzureDiskVolumeSource", - "description": "azureDisk represents an Azure Data Disk mount on the host and bind mount to the pod." + "description": "azureDisk represents an Azure Data Disk mount on the host and bind mount to the pod. Deprecated: AzureDisk is deprecated. All operations for the in-tree azureDisk type are redirected to the disk.csi.azure.com CSI driver." }, "azureFile": { "$ref": "#/definitions/v1.AzureFilePersistentVolumeSource", - "description": "azureFile represents an Azure File Service mount on the host and bind mount to the pod." + "description": "azureFile represents an Azure File Service mount on the host and bind mount to the pod. Deprecated: AzureFile is deprecated. All operations for the in-tree azureFile type are redirected to the file.csi.azure.com CSI driver." }, "capacity": { "additionalProperties": { @@ -7439,11 +9450,11 @@ }, "cephfs": { "$ref": "#/definitions/v1.CephFSPersistentVolumeSource", - "description": "cephFS represents a Ceph FS mount on the host that shares a pod's lifetime" + "description": "cephFS represents a Ceph FS mount on the host that shares a pod's lifetime. Deprecated: CephFS is deprecated and the in-tree cephfs type is no longer supported." }, "cinder": { "$ref": "#/definitions/v1.CinderPersistentVolumeSource", - "description": "cinder represents a cinder volume attached and mounted on kubelets host machine. More info: https://examples.k8s.io/mysql-cinder-pd/README.md" + "description": "cinder represents a cinder volume attached and mounted on kubelets host machine. Deprecated: Cinder is deprecated. All operations for the in-tree cinder type are redirected to the cinder.csi.openstack.org CSI driver. More info: https://examples.k8s.io/mysql-cinder-pd/README.md" }, "claimRef": { "$ref": "#/definitions/v1.ObjectReference", @@ -7452,7 +9463,7 @@ }, "csi": { "$ref": "#/definitions/v1.CSIPersistentVolumeSource", - "description": "csi represents storage that is handled by an external CSI driver (Beta feature)." + "description": "csi represents storage that is handled by an external CSI driver." }, "fc": { "$ref": "#/definitions/v1.FCVolumeSource", @@ -7460,19 +9471,19 @@ }, "flexVolume": { "$ref": "#/definitions/v1.FlexPersistentVolumeSource", - "description": "flexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin." + "description": "flexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin. Deprecated: FlexVolume is deprecated. Consider using a CSIDriver instead." }, "flocker": { "$ref": "#/definitions/v1.FlockerVolumeSource", - "description": "flocker represents a Flocker volume attached to a kubelet's host machine and exposed to the pod for its usage. This depends on the Flocker control service being running" + "description": "flocker represents a Flocker volume attached to a kubelet's host machine and exposed to the pod for its usage. This depends on the Flocker control service being running. Deprecated: Flocker is deprecated and the in-tree flocker type is no longer supported." }, "gcePersistentDisk": { "$ref": "#/definitions/v1.GCEPersistentDiskVolumeSource", - "description": "gcePersistentDisk represents a GCE Disk resource that is attached to a kubelet's host machine and then exposed to the pod. Provisioned by an admin. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk" + "description": "gcePersistentDisk represents a GCE Disk resource that is attached to a kubelet's host machine and then exposed to the pod. Provisioned by an admin. Deprecated: GCEPersistentDisk is deprecated. All operations for the in-tree gcePersistentDisk type are redirected to the pd.csi.storage.gke.io CSI driver. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk" }, "glusterfs": { "$ref": "#/definitions/v1.GlusterfsPersistentVolumeSource", - "description": "glusterfs represents a Glusterfs volume that is attached to a host and exposed to the pod. Provisioned by an admin. More info: https://examples.k8s.io/volumes/glusterfs/README.md" + "description": "glusterfs represents a Glusterfs volume that is attached to a host and exposed to the pod. Provisioned by an admin. Deprecated: Glusterfs is deprecated and the in-tree glusterfs type is no longer supported. More info: https://examples.k8s.io/volumes/glusterfs/README.md" }, "hostPath": { "$ref": "#/definitions/v1.HostPathVolumeSource", @@ -7491,7 +9502,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "nfs": { "$ref": "#/definitions/v1.NFSVolumeSource", @@ -7502,28 +9514,28 @@ "description": "nodeAffinity defines constraints that limit what nodes this volume can be accessed from. This field influences the scheduling of pods that use this volume." }, "persistentVolumeReclaimPolicy": { - "description": "persistentVolumeReclaimPolicy defines what happens to a persistent volume when released from its claim. Valid options are Retain (default for manually created PersistentVolumes), Delete (default for dynamically provisioned PersistentVolumes), and Recycle (deprecated). Recycle must be supported by the volume plugin underlying this PersistentVolume. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#reclaiming\n\n", + "description": "persistentVolumeReclaimPolicy defines what happens to a persistent volume when released from its claim. Valid options are Retain (default for manually created PersistentVolumes), Delete (default for dynamically provisioned PersistentVolumes), and Recycle (deprecated). Recycle must be supported by the volume plugin underlying this PersistentVolume. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#reclaiming", "type": "string" }, "photonPersistentDisk": { "$ref": "#/definitions/v1.PhotonPersistentDiskVolumeSource", - "description": "photonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine" + "description": "photonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine. Deprecated: PhotonPersistentDisk is deprecated and the in-tree photonPersistentDisk type is no longer supported." }, "portworxVolume": { "$ref": "#/definitions/v1.PortworxVolumeSource", - "description": "portworxVolume represents a portworx volume attached and mounted on kubelets host machine" + "description": "portworxVolume represents a portworx volume attached and mounted on kubelets host machine. Deprecated: PortworxVolume is deprecated. All operations for the in-tree portworxVolume type are redirected to the pxd.portworx.com CSI driver when the CSIMigrationPortworx feature-gate is on." }, "quobyte": { "$ref": "#/definitions/v1.QuobyteVolumeSource", - "description": "quobyte represents a Quobyte mount on the host that shares a pod's lifetime" + "description": "quobyte represents a Quobyte mount on the host that shares a pod's lifetime. Deprecated: Quobyte is deprecated and the in-tree quobyte type is no longer supported." }, "rbd": { "$ref": "#/definitions/v1.RBDPersistentVolumeSource", - "description": "rbd represents a Rados Block Device mount on the host that shares a pod's lifetime. More info: https://examples.k8s.io/volumes/rbd/README.md" + "description": "rbd represents a Rados Block Device mount on the host that shares a pod's lifetime. Deprecated: RBD is deprecated and the in-tree rbd type is no longer supported. More info: https://examples.k8s.io/volumes/rbd/README.md" }, "scaleIO": { "$ref": "#/definitions/v1.ScaleIOPersistentVolumeSource", - "description": "scaleIO represents a ScaleIO persistent volume attached and mounted on Kubernetes nodes." + "description": "scaleIO represents a ScaleIO persistent volume attached and mounted on Kubernetes nodes. Deprecated: ScaleIO is deprecated and the in-tree scaleIO type is no longer supported." }, "storageClassName": { "description": "storageClassName is the name of StorageClass to which this persistent volume belongs. Empty value means that this volume does not belong to any StorageClass.", @@ -7531,7 +9543,11 @@ }, "storageos": { "$ref": "#/definitions/v1.StorageOSPersistentVolumeSource", - "description": "storageOS represents a StorageOS volume that is attached to the kubelet's host machine and mounted into the pod More info: https://examples.k8s.io/volumes/storageos/README.md" + "description": "storageOS represents a StorageOS volume that is attached to the kubelet's host machine and mounted into the pod. Deprecated: StorageOS is deprecated and the in-tree storageos type is no longer supported. More info: https://examples.k8s.io/volumes/storageos/README.md" + }, + "volumeAttributesClassName": { + "description": "Name of VolumeAttributesClass to which this persistent volume belongs. Empty value is not allowed. When this field is not set, it indicates that this volume does not belong to any VolumeAttributesClass. This field is mutable and can be changed by the CSI driver after a volume has been updated successfully to a new class. For an unbound PersistentVolume, the volumeAttributesClassName will be matched with unbound PersistentVolumeClaims during the binding process.", + "type": "string" }, "volumeMode": { "description": "volumeMode defines if a volume is intended to be used with a formatted filesystem or to remain in raw block state. Value of Filesystem is implied when not included in spec.", @@ -7539,7 +9555,7 @@ }, "vsphereVolume": { "$ref": "#/definitions/v1.VsphereVirtualDiskVolumeSource", - "description": "vsphereVolume represents a vSphere volume attached and mounted on kubelets host machine" + "description": "vsphereVolume represents a vSphere volume attached and mounted on kubelets host machine. Deprecated: VsphereVolume is deprecated. All operations for the in-tree vsphereVolume type are redirected to the csi.vsphere.vmware.com CSI driver." } }, "type": "object" @@ -7547,12 +9563,17 @@ "v1.PersistentVolumeStatus": { "description": "PersistentVolumeStatus is the current status of a persistent volume.", "properties": { + "lastPhaseTransitionTime": { + "description": "lastPhaseTransitionTime is the time the phase transitioned from one to another and automatically resets to current time everytime a volume phase transitions.", + "format": "date-time", + "type": "string" + }, "message": { "description": "message is a human-readable message indicating details about why the volume is in this state.", "type": "string" }, "phase": { - "description": "phase indicates if a volume is available, bound to a claim, or released by a claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#phase\n\n", + "description": "phase indicates if a volume is available, bound to a claim, or released by a claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#phase", "type": "string" }, "reason": { @@ -7620,14 +9641,16 @@ "items": { "$ref": "#/definitions/v1.WeightedPodAffinityTerm" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "requiredDuringSchedulingIgnoredDuringExecution": { "description": "If the affinity requirements specified by this field are not met at scheduling time, the pod will not be scheduled onto the node. If the affinity requirements specified by this field cease to be met at some point during pod execution (e.g. due to a pod label update), the system may or may not try to eventually evict the pod from its node. When there are multiple elements, the lists of nodes corresponding to each podAffinityTerm are intersected, i.e. all terms must be satisfied.", "items": { "$ref": "#/definitions/v1.PodAffinityTerm" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object" @@ -7637,7 +9660,23 @@ "properties": { "labelSelector": { "$ref": "#/definitions/v1.LabelSelector", - "description": "A label query over a set of resources, in this case pods." + "description": "A label query over a set of resources, in this case pods. If it's null, this PodAffinityTerm matches with no Pods." + }, + "matchLabelKeys": { + "description": "MatchLabelKeys is a set of pod label keys to select which pods will be taken into consideration. The keys are used to lookup values from the incoming pod labels, those key-value labels are merged with `labelSelector` as `key in (value)` to select the group of existing pods which pods will be taken into consideration for the incoming pod's pod (anti) affinity. Keys that don't exist in the incoming pod labels will be ignored. The default value is empty. The same key is forbidden to exist in both matchLabelKeys and labelSelector. Also, matchLabelKeys cannot be set when labelSelector isn't set.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "mismatchLabelKeys": { + "description": "MismatchLabelKeys is a set of pod label keys to select which pods will be taken into consideration. The keys are used to lookup values from the incoming pod labels, those key-value labels are merged with `labelSelector` as `key notin (value)` to select the group of existing pods which pods will be taken into consideration for the incoming pod's pod (anti) affinity. Keys that don't exist in the incoming pod labels will be ignored. The default value is empty. The same key is forbidden to exist in both mismatchLabelKeys and labelSelector. Also, mismatchLabelKeys cannot be set when labelSelector isn't set.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" }, "namespaceSelector": { "$ref": "#/definitions/v1.LabelSelector", @@ -7648,7 +9687,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "topologyKey": { "description": "This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching the labelSelector in the specified namespaces, where co-located is defined as running on a node whose value of the label with key topologyKey matches that of any node on which any of the selected pods is running. Empty topologyKey is not allowed.", @@ -7664,20 +9704,57 @@ "description": "Pod anti affinity is a group of inter pod anti affinity scheduling rules.", "properties": { "preferredDuringSchedulingIgnoredDuringExecution": { - "description": "The scheduler will prefer to schedule pods to nodes that satisfy the anti-affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions. The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling anti-affinity expressions, etc.), compute a sum by iterating through the elements of this field and adding \"weight\" to the sum if the node has pods which matches the corresponding podAffinityTerm; the node(s) with the highest sum are the most preferred.", + "description": "The scheduler will prefer to schedule pods to nodes that satisfy the anti-affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions. The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling anti-affinity expressions, etc.), compute a sum by iterating through the elements of this field and subtracting \"weight\" from the sum if the node has pods which matches the corresponding podAffinityTerm; the node(s) with the highest sum are the most preferred.", "items": { "$ref": "#/definitions/v1.WeightedPodAffinityTerm" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "requiredDuringSchedulingIgnoredDuringExecution": { "description": "If the anti-affinity requirements specified by this field are not met at scheduling time, the pod will not be scheduled onto the node. If the anti-affinity requirements specified by this field cease to be met at some point during pod execution (e.g. due to a pod label update), the system may or may not try to eventually evict the pod from its node. When there are multiple elements, the lists of nodes corresponding to each podAffinityTerm are intersected, i.e. all terms must be satisfied.", "items": { "$ref": "#/definitions/v1.PodAffinityTerm" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" + } + }, + "type": "object" + }, + "v1.PodCertificateProjection": { + "description": "PodCertificateProjection provides a private key and X.509 certificate in the pod filesystem.", + "properties": { + "certificateChainPath": { + "description": "Write the certificate chain at this path in the projected volume.\n\nMost applications should use credentialBundlePath. When using keyPath and certificateChainPath, your application needs to check that the key and leaf certificate are consistent, because it is possible to read the files mid-rotation.", + "type": "string" + }, + "credentialBundlePath": { + "description": "Write the credential bundle at this path in the projected volume.\n\nThe credential bundle is a single file that contains multiple PEM blocks. The first PEM block is a PRIVATE KEY block, containing a PKCS#8 private key.\n\nThe remaining blocks are CERTIFICATE blocks, containing the issued certificate chain from the signer (leaf and any intermediates).\n\nUsing credentialBundlePath lets your Pod's application code make a single atomic read that retrieves a consistent key and certificate chain. If you project them to separate files, your application code will need to additionally check that the leaf certificate was issued to the key.", + "type": "string" + }, + "keyPath": { + "description": "Write the key at this path in the projected volume.\n\nMost applications should use credentialBundlePath. When using keyPath and certificateChainPath, your application needs to check that the key and leaf certificate are consistent, because it is possible to read the files mid-rotation.", + "type": "string" + }, + "keyType": { + "description": "The type of keypair Kubelet will generate for the pod.\n\nValid values are \"RSA3072\", \"RSA4096\", \"ECDSAP256\", \"ECDSAP384\", \"ECDSAP521\", and \"ED25519\".", + "type": "string" + }, + "maxExpirationSeconds": { + "description": "maxExpirationSeconds is the maximum lifetime permitted for the certificate.\n\nKubelet copies this value verbatim into the PodCertificateRequests it generates for this projection.\n\nIf omitted, kube-apiserver will set it to 86400(24 hours). kube-apiserver will reject values shorter than 3600 (1 hour). The maximum allowable value is 7862400 (91 days).\n\nThe signer implementation is then free to issue a certificate with any lifetime *shorter* than MaxExpirationSeconds, but no shorter than 3600 seconds (1 hour). This constraint is enforced by kube-apiserver. `kubernetes.io` signers will never issue certificates with a lifetime longer than 24 hours.", + "format": "int32", + "type": "integer" + }, + "signerName": { + "description": "Kubelet's generated CSRs will be addressed to this signer.", + "type": "string" } }, + "required": [ + "signerName", + "keyType" + ], "type": "object" }, "v1.PodCondition": { @@ -7697,6 +9774,11 @@ "description": "Human-readable message indicating details about last transition.", "type": "string" }, + "observedGeneration": { + "description": "If set, this represents the .metadata.generation that the pod condition was set based upon. This is an alpha field. Enable PodObservedGenerationTracking to be able to use this field.", + "format": "int64", + "type": "integer" + }, "reason": { "description": "Unique, one-word, CamelCase reason for the condition's last transition.", "type": "string" @@ -7724,21 +9806,24 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "options": { "description": "A list of DNS resolver options. This will be merged with the base options generated from DNSPolicy. Duplicated entries will be removed. Resolution options given in Options will override those that appear in the base DNSPolicy.", "items": { "$ref": "#/definitions/v1.PodDNSConfigOption" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "searches": { "description": "A list of DNS search domains for host-name lookup. This will be appended to the base search paths generated from DNSPolicy. Duplicated search paths will be removed.", "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object" @@ -7747,23 +9832,49 @@ "description": "PodDNSConfigOption defines DNS resolver options of a pod.", "properties": { "name": { - "description": "Required.", + "description": "Name is this DNS resolver option's name. Required.", "type": "string" }, "value": { + "description": "Value is this DNS resolver option's value.", "type": "string" } }, "type": "object" }, + "v1.PodExtendedResourceClaimStatus": { + "description": "PodExtendedResourceClaimStatus is stored in the PodStatus for the extended resource requests backed by DRA. It stores the generated name for the corresponding special ResourceClaim created by the scheduler.", + "properties": { + "requestMappings": { + "description": "RequestMappings identifies the mapping of to device request in the generated ResourceClaim.", + "items": { + "$ref": "#/definitions/v1.ContainerExtendedResourceRequest" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "resourceClaimName": { + "description": "ResourceClaimName is the name of the ResourceClaim that was generated for the Pod in the namespace of the Pod.", + "type": "string" + } + }, + "required": [ + "requestMappings", + "resourceClaimName" + ], + "type": "object" + }, "v1.PodIP": { - "description": "IP address information for entries in the (plural) PodIPs field. Each entry includes:\n\n\tIP: An IP address allocated to the pod. Routable at least within the cluster.", + "description": "PodIP represents a single IP address allocated to the pod.", "properties": { "ip": { - "description": "ip is an IP address (IPv4 or IPv6) assigned to the pod", + "description": "IP is the IP address assigned to the pod", "type": "string" } }, + "required": [ + "ip" + ], "type": "object" }, "v1.PodList": { @@ -7827,9 +9938,64 @@ ], "type": "object" }, + "v1.PodResourceClaim": { + "description": "PodResourceClaim references exactly one ResourceClaim, either directly or by naming a ResourceClaimTemplate which is then turned into a ResourceClaim for the pod.\n\nIt adds a name to it that uniquely identifies the ResourceClaim inside the Pod. Containers that need access to the ResourceClaim reference it with this name.", + "properties": { + "name": { + "description": "Name uniquely identifies this resource claim inside the pod. This must be a DNS_LABEL.", + "type": "string" + }, + "resourceClaimName": { + "description": "ResourceClaimName is the name of a ResourceClaim object in the same namespace as this pod.\n\nExactly one of ResourceClaimName and ResourceClaimTemplateName must be set.", + "type": "string" + }, + "resourceClaimTemplateName": { + "description": "ResourceClaimTemplateName is the name of a ResourceClaimTemplate object in the same namespace as this pod.\n\nThe template will be used to create a new ResourceClaim, which will be bound to this pod. When this pod is deleted, the ResourceClaim will also be deleted. The pod name and resource name, along with a generated component, will be used to form a unique name for the ResourceClaim, which will be recorded in pod.status.resourceClaimStatuses.\n\nThis field is immutable and no changes will be made to the corresponding ResourceClaim by the control plane after creating the ResourceClaim.\n\nExactly one of ResourceClaimName and ResourceClaimTemplateName must be set.", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "v1.PodResourceClaimStatus": { + "description": "PodResourceClaimStatus is stored in the PodStatus for each PodResourceClaim which references a ResourceClaimTemplate. It stores the generated name for the corresponding ResourceClaim.", + "properties": { + "name": { + "description": "Name uniquely identifies this resource claim inside the pod. This must match the name of an entry in pod.spec.resourceClaims, which implies that the string must be a DNS_LABEL.", + "type": "string" + }, + "resourceClaimName": { + "description": "ResourceClaimName is the name of the ResourceClaim that was generated for the Pod in the namespace of the Pod. If this is unset, then generating a ResourceClaim was not necessary. The pod.spec.resourceClaims entry can be ignored in this case.", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "v1.PodSchedulingGate": { + "description": "PodSchedulingGate is associated to a Pod to guard its scheduling.", + "properties": { + "name": { + "description": "Name of the scheduling gate. Each scheduling gate must have a unique name field.", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, "v1.PodSecurityContext": { "description": "PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext. Field values of container.securityContext take precedence over field values of PodSecurityContext.", "properties": { + "appArmorProfile": { + "$ref": "#/definitions/v1.AppArmorProfile", + "description": "appArmorProfile is the AppArmor options to use by the containers in this pod. Note that this field cannot be set when spec.os.name is windows." + }, "fsGroup": { "description": "A special supplemental group that applies to all containers in a pod. Some volume types allow the Kubelet to change the ownership of that volume to be owned by the pod:\n\n1. The owning GID will be the FSGroup 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) 3. The permission bits are OR'd with rw-rw----\n\nIf unset, the Kubelet will not modify the ownership and permissions of any volume. Note that this field cannot be set when spec.os.name is windows.", "format": "int64", @@ -7853,6 +10019,10 @@ "format": "int64", "type": "integer" }, + "seLinuxChangePolicy": { + "description": "seLinuxChangePolicy defines how the container's SELinux label is applied to all volumes used by the Pod. It has no effect on nodes that do not support SELinux or to volumes does not support SELinux. Valid values are \"MountOption\" and \"Recursive\".\n\n\"Recursive\" means relabeling of all files on all Pod volumes by the container runtime. This may be slow for large volumes, but allows mixing privileged and unprivileged Pods sharing the same volume on the same node.\n\n\"MountOption\" mounts all eligible Pod volumes with `-o context` mount option. This requires all Pods that share the same volume to use the same SELinux label. It is not possible to share the same volume among privileged and unprivileged Pods. Eligible volumes are in-tree FibreChannel and iSCSI volumes, and all CSI volumes whose CSI driver announces SELinux support by setting spec.seLinuxMount: true in their CSIDriver instance. Other volumes are always re-labelled recursively. \"MountOption\" value is allowed only when SELinuxMount feature gate is enabled.\n\nIf not specified and SELinuxMount feature gate is enabled, \"MountOption\" is used. If not specified and SELinuxMount feature gate is disabled, \"MountOption\" is used for ReadWriteOncePod volumes and \"Recursive\" for all other volumes.\n\nThis field affects only Pods that have SELinux label set, either in PodSecurityContext or in SecurityContext of all containers.\n\nAll Pods that use the same volume should use the same seLinuxChangePolicy, otherwise some pods can get stuck in ContainerCreating state. Note that this field cannot be set when spec.os.name is windows.", + "type": "string" + }, "seLinuxOptions": { "$ref": "#/definitions/v1.SELinuxOptions", "description": "The SELinux context to be applied to all containers. If unspecified, the container runtime will allocate a random SELinux context for each container. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence for that container. Note that this field cannot be set when spec.os.name is windows." @@ -7862,19 +10032,25 @@ "description": "The seccomp options to use by the containers in this pod. Note that this field cannot be set when spec.os.name is windows." }, "supplementalGroups": { - "description": "A list of groups applied to the first process run in each container, in addition to the container's primary GID. If unspecified, no groups will be added to any container. Note that this field cannot be set when spec.os.name is windows.", + "description": "A list of groups applied to the first process run in each container, in addition to the container's primary GID and fsGroup (if specified). If the SupplementalGroupsPolicy feature is enabled, the supplementalGroupsPolicy field determines whether these are in addition to or instead of any group memberships defined in the container image. If unspecified, no additional groups are added, though group memberships defined in the container image may still be used, depending on the supplementalGroupsPolicy field. Note that this field cannot be set when spec.os.name is windows.", "items": { "format": "int64", "type": "integer" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "supplementalGroupsPolicy": { + "description": "Defines how supplemental groups of the first container processes are calculated. Valid values are \"Merge\" and \"Strict\". If not specified, \"Merge\" is used. (Alpha) Using the field requires the SupplementalGroupsPolicy feature gate to be enabled and the container runtime must implement support for this feature. Note that this field cannot be set when spec.os.name is windows.", + "type": "string" }, "sysctls": { "description": "Sysctls hold a list of namespaced sysctls used for the pod. Pods with unsupported sysctls (by the container runtime) might fail to launch. Note that this field cannot be set when spec.os.name is windows.", "items": { "$ref": "#/definitions/v1.Sysctl" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "windowsOptions": { "$ref": "#/definitions/v1.WindowsSecurityContextOptions", @@ -7905,6 +10081,10 @@ "$ref": "#/definitions/v1.Container" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "name", "x-kubernetes-patch-strategy": "merge" }, @@ -7913,7 +10093,7 @@ "description": "Specifies the DNS parameters of a pod. Parameters specified here will be merged to the generated DNS configuration based on DNSPolicy." }, "dnsPolicy": { - "description": "Set DNS policy for the pod. Defaults to \"ClusterFirst\". Valid values are 'ClusterFirstWithHostNet', 'ClusterFirst', 'Default' or 'None'. DNS parameters given in DNSConfig will be merged with the policy selected with DNSPolicy. To have DNS options set along with hostNetwork, you have to specify DNS policy explicitly to 'ClusterFirstWithHostNet'.\n\n", + "description": "Set DNS policy for the pod. Defaults to \"ClusterFirst\". Valid values are 'ClusterFirstWithHostNet', 'ClusterFirst', 'Default' or 'None'. DNS parameters given in DNSConfig will be merged with the policy selected with DNSPolicy. To have DNS options set along with hostNetwork, you have to specify DNS policy explicitly to 'ClusterFirstWithHostNet'.", "type": "string" }, "enableServiceLinks": { @@ -7926,15 +10106,23 @@ "$ref": "#/definitions/v1.EphemeralContainer" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "name", "x-kubernetes-patch-strategy": "merge" }, "hostAliases": { - "description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods.", + "description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified.", "items": { "$ref": "#/definitions/v1.HostAlias" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "ip" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "ip", "x-kubernetes-patch-strategy": "merge" }, @@ -7943,7 +10131,7 @@ "type": "boolean" }, "hostNetwork": { - "description": "Host networking requested for this pod. Use the host's network namespace. If this option is set, the ports that will be used must be specified. Default to false.", + "description": "Host networking requested for this pod. Use the host's network namespace. When using HostNetwork you should specify ports so the scheduler is aware. When `hostNetwork` is true, specified `hostPort` fields in port definitions must match `containerPort`, and unspecified `hostPort` fields in port definitions are defaulted to match `containerPort`. Default to false.", "type": "boolean" }, "hostPID": { @@ -7958,26 +10146,38 @@ "description": "Specifies the hostname of the Pod If not specified, the pod's hostname will be set to a system-defined value.", "type": "string" }, + "hostnameOverride": { + "description": "HostnameOverride specifies an explicit override for the pod's hostname as perceived by the pod. This field only specifies the pod's hostname and does not affect its DNS records. When this field is set to a non-empty string: - It takes precedence over the values set in `hostname` and `subdomain`. - The Pod's hostname will be set to this value. - `setHostnameAsFQDN` must be nil or set to false. - `hostNetwork` must be set to false.\n\nThis field must be a valid DNS subdomain as defined in RFC 1123 and contain at most 64 characters. Requires the HostnameOverride feature gate to be enabled.", + "type": "string" + }, "imagePullSecrets": { "description": "ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for them to use. More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod", "items": { "$ref": "#/definitions/v1.LocalObjectReference" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "name", "x-kubernetes-patch-strategy": "merge" }, "initContainers": { - "description": "List of initialization containers belonging to the pod. Init containers are executed in order prior to containers being started. If any init container fails, the pod is considered to have failed and is handled according to its restartPolicy. The name for an init container or normal container must be unique among all containers. Init containers may not have Lifecycle actions, Readiness probes, Liveness probes, or Startup probes. The resourceRequirements of an init container are taken into account during scheduling by finding the highest request/limit for each resource type, and then using the max of of that value or the sum of the normal containers. Limits are applied to init containers in a similar fashion. Init containers cannot currently be added or removed. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/", + "description": "List of initialization containers belonging to the pod. Init containers are executed in order prior to containers being started. If any init container fails, the pod is considered to have failed and is handled according to its restartPolicy. The name for an init container or normal container must be unique among all containers. Init containers may not have Lifecycle actions, Readiness probes, Liveness probes, or Startup probes. The resourceRequirements of an init container are taken into account during scheduling by finding the highest request/limit for each resource type, and then using the max of that value or the sum of the normal containers. Limits are applied to init containers in a similar fashion. Init containers cannot currently be added or removed. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/", "items": { "$ref": "#/definitions/v1.Container" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "name", "x-kubernetes-patch-strategy": "merge" }, "nodeName": { - "description": "NodeName is a request to schedule this pod onto a specific node. If it is non-empty, the scheduler simply schedules this pod onto that node, assuming that it fits resource requirements.", + "description": "NodeName indicates in which node this pod is scheduled. If empty, this pod is a candidate for scheduling by the scheduler defined in schedulerName. Once this field is set, the kubelet for this node becomes responsible for the lifecycle of this pod. This field should not be used to express a desire for the pod to be scheduled on a specific node. https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodename", "type": "string" }, "nodeSelector": { @@ -7990,7 +10190,7 @@ }, "os": { "$ref": "#/definitions/v1.PodOS", - "description": "Specifies the OS of the containers in the pod. Some pod and container fields are restricted if this is set.\n\nIf the OS field is set to linux, the following fields must be unset: -securityContext.windowsOptions\n\nIf the OS field is set to windows, following fields must be unset: - spec.hostPID - spec.hostIPC - spec.hostUsers - spec.securityContext.seLinuxOptions - spec.securityContext.seccompProfile - spec.securityContext.fsGroup - spec.securityContext.fsGroupChangePolicy - spec.securityContext.sysctls - spec.shareProcessNamespace - spec.securityContext.runAsUser - spec.securityContext.runAsGroup - spec.securityContext.supplementalGroups - spec.containers[*].securityContext.seLinuxOptions - spec.containers[*].securityContext.seccompProfile - spec.containers[*].securityContext.capabilities - spec.containers[*].securityContext.readOnlyRootFilesystem - spec.containers[*].securityContext.privileged - spec.containers[*].securityContext.allowPrivilegeEscalation - spec.containers[*].securityContext.procMount - spec.containers[*].securityContext.runAsUser - spec.containers[*].securityContext.runAsGroup" + "description": "Specifies the OS of the containers in the pod. Some pod and container fields are restricted if this is set.\n\nIf the OS field is set to linux, the following fields must be unset: -securityContext.windowsOptions\n\nIf the OS field is set to windows, following fields must be unset: - spec.hostPID - spec.hostIPC - spec.hostUsers - spec.resources - spec.securityContext.appArmorProfile - spec.securityContext.seLinuxOptions - spec.securityContext.seccompProfile - spec.securityContext.fsGroup - spec.securityContext.fsGroupChangePolicy - spec.securityContext.sysctls - spec.shareProcessNamespace - spec.securityContext.runAsUser - spec.securityContext.runAsGroup - spec.securityContext.supplementalGroups - spec.securityContext.supplementalGroupsPolicy - spec.containers[*].securityContext.appArmorProfile - spec.containers[*].securityContext.seLinuxOptions - spec.containers[*].securityContext.seccompProfile - spec.containers[*].securityContext.capabilities - spec.containers[*].securityContext.readOnlyRootFilesystem - spec.containers[*].securityContext.privileged - spec.containers[*].securityContext.allowPrivilegeEscalation - spec.containers[*].securityContext.procMount - spec.containers[*].securityContext.runAsUser - spec.containers[*].securityContext.runAsGroup" }, "overhead": { "additionalProperties": { @@ -8017,10 +10217,28 @@ "items": { "$ref": "#/definitions/v1.PodReadinessGate" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "resourceClaims": { + "description": "ResourceClaims defines which ResourceClaims must be allocated and reserved before the Pod is allowed to start. The resources will be made available to those containers which consume them by name.\n\nThis is an alpha field and requires enabling the DynamicResourceAllocation feature gate.\n\nThis field is immutable.", + "items": { + "$ref": "#/definitions/v1.PodResourceClaim" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge,retainKeys" + }, + "resources": { + "$ref": "#/definitions/v1.ResourceRequirements", + "description": "Resources is the total amount of CPU and Memory resources required by all containers in the pod. It supports specifying Requests and Limits for \"cpu\", \"memory\" and \"hugepages-\" resource names only. ResourceClaims are not supported.\n\nThis field enables fine-grained control over resource allocation for the entire pod, allowing resource sharing among containers in a pod.\n\nThis is an alpha field and requires enabling the PodLevelResources feature gate." }, "restartPolicy": { - "description": "Restart policy for all containers within the pod. One of Always, OnFailure, Never. Default to Always. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy\n\n", + "description": "Restart policy for all containers within the pod. One of Always, OnFailure, Never. In some contexts, only a subset of those values may be permitted. Default to Always. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy", "type": "string" }, "runtimeClassName": { @@ -8031,12 +10249,25 @@ "description": "If specified, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler.", "type": "string" }, + "schedulingGates": { + "description": "SchedulingGates is an opaque list of values that if specified will block scheduling the pod. If schedulingGates is not empty, the pod will stay in the SchedulingGated state and the scheduler will not attempt to schedule the pod.\n\nSchedulingGates can only be set at pod creation time, and be removed only afterwards.", + "items": { + "$ref": "#/definitions/v1.PodSchedulingGate" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + }, "securityContext": { "$ref": "#/definitions/v1.PodSecurityContext", "description": "SecurityContext holds pod-level security attributes and common container settings. Optional: Defaults to empty. See type description for default values of each field." }, "serviceAccount": { - "description": "DeprecatedServiceAccount is a depreciated alias for ServiceAccountName. Deprecated: Use serviceAccountName instead.", + "description": "DeprecatedServiceAccount is a deprecated alias for ServiceAccountName. Deprecated: Use serviceAccountName instead.", "type": "string" }, "serviceAccountName": { @@ -8044,7 +10275,7 @@ "type": "string" }, "setHostnameAsFQDN": { - "description": "If true the pod's hostname will be configured as the pod's FQDN, rather than the leaf name (the default). In Linux containers, this means setting the FQDN in the hostname field of the kernel (the nodename field of struct utsname). In Windows containers, this means setting the registry value of hostname for the registry key HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters to FQDN. If a pod does not have FQDN, this has no effect. Default to false.", + "description": "If true the pod's hostname will be configured as the pod's FQDN, rather than the leaf name (the default). In Linux containers, this means setting the FQDN in the hostname field of the kernel (the nodename field of struct utsname). In Windows containers, this means setting the registry value of hostname for the registry key HKEY_LOCAL_MACHINE\\\\SYSTEM\\\\CurrentControlSet\\\\Services\\\\Tcpip\\\\Parameters to FQDN. If a pod does not have FQDN, this has no effect. Default to false.", "type": "boolean" }, "shareProcessNamespace": { @@ -8065,7 +10296,8 @@ "items": { "$ref": "#/definitions/v1.Toleration" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "topologySpreadConstraints": { "description": "TopologySpreadConstraints describes how a group of pods ought to spread across topology domains. Scheduler will schedule pods in a way which abides by the constraints. All topologySpreadConstraints are ANDed.", @@ -8087,6 +10319,10 @@ "$ref": "#/definitions/v1.Volume" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "name", "x-kubernetes-patch-strategy": "merge,retainKeys" } @@ -8105,33 +10341,54 @@ "$ref": "#/definitions/v1.PodCondition" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "type", "x-kubernetes-patch-strategy": "merge" }, "containerStatuses": { - "description": "The list has one entry per container in the manifest. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-and-container-status", + "description": "Statuses of containers in this pod. Each container in the pod should have at most one status in this list, and all statuses should be for containers in the pod. However this is not enforced. If a status for a non-existent container is present in the list, or the list has duplicate names, the behavior of various Kubernetes components is not defined and those statuses might be ignored. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-and-container-status", "items": { "$ref": "#/definitions/v1.ContainerStatus" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "ephemeralContainerStatuses": { - "description": "Status for any ephemeral containers that have run in this pod.", + "description": "Statuses for any ephemeral containers that have run in this pod. Each ephemeral container in the pod should have at most one status in this list, and all statuses should be for containers in the pod. However this is not enforced. If a status for a non-existent container is present in the list, or the list has duplicate names, the behavior of various Kubernetes components is not defined and those statuses might be ignored. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-and-container-status", "items": { "$ref": "#/definitions/v1.ContainerStatus" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "extendedResourceClaimStatus": { + "$ref": "#/definitions/v1.PodExtendedResourceClaimStatus", + "description": "Status of extended resource claim backed by DRA." }, "hostIP": { - "description": "IP address of the host to which the pod is assigned. Empty if not yet scheduled.", + "description": "hostIP holds the IP address of the host to which the pod is assigned. Empty if the pod has not started yet. A pod can be assigned to a node that has a problem in kubelet which in turns mean that HostIP will not be updated even if there is a node is assigned to pod", "type": "string" }, + "hostIPs": { + "description": "hostIPs holds the IP addresses allocated to the host. If this field is specified, the first entry must match the hostIP field. This list is empty if the pod has not started yet. A pod can be assigned to a node that has a problem in kubelet which in turns means that HostIPs will not be updated even if there is a node is assigned to this pod.", + "items": { + "$ref": "#/definitions/v1.HostIP" + }, + "type": "array", + "x-kubernetes-list-type": "atomic", + "x-kubernetes-patch-merge-key": "ip", + "x-kubernetes-patch-strategy": "merge" + }, "initContainerStatuses": { - "description": "The list has one entry per init container in the manifest. The most recent successful init container will have ready = true, the most recently started container will have startTime set. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-and-container-status", + "description": "Statuses of init containers in this pod. The most recent successful non-restartable init container will have ready = true, the most recently started container will have startTime set. Each init container in the pod should have at most one status in this list, and all statuses should be for containers in the pod. However this is not enforced. If a status for a non-existent container is present in the list, or the list has duplicate names, the behavior of various Kubernetes components is not defined and those statuses might be ignored. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-and-container-status", "items": { "$ref": "#/definitions/v1.ContainerStatus" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "message": { "description": "A human readable message indicating details about why the pod is in this condition.", @@ -8141,12 +10398,17 @@ "description": "nominatedNodeName is set only when this pod preempts other pods on the node, but it cannot be scheduled right away as preemption victims receive their graceful termination periods. This field does not guarantee that the pod will be scheduled on this node. Scheduler may decide to place the pod elsewhere if other nodes become available sooner. Scheduler may also decide to give the resources on this node to a higher priority pod that is created after preemption. As a result, this field may be different than PodSpec.nodeName when the pod is scheduled.", "type": "string" }, + "observedGeneration": { + "description": "If set, this represents the .metadata.generation that the pod status was set based upon. This is an alpha field. Enable PodObservedGenerationTracking to be able to use this field.", + "format": "int64", + "type": "integer" + }, "phase": { - "description": "The phase of a Pod is a simple, high-level summary of where the Pod is in its lifecycle. The conditions array, the reason and message fields, and the individual container status arrays contain more detail about the pod's status. There are five possible phase values:\n\nPending: The pod has been accepted by the Kubernetes system, but one or more of the container images has not been created. This includes time before being scheduled as well as time spent downloading images over the network, which could take a while. Running: The pod has been bound to a node, and all of the containers have been created. At least one container is still running, or is in the process of starting or restarting. Succeeded: All containers in the pod have terminated in success, and will not be restarted. Failed: All containers in the pod have terminated, and at least one container has terminated in failure. The container either exited with non-zero status or was terminated by the system. Unknown: For some reason the state of the pod could not be obtained, typically due to an error in communicating with the host of the pod.\n\nMore info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-phase\n\n", + "description": "The phase of a Pod is a simple, high-level summary of where the Pod is in its lifecycle. The conditions array, the reason and message fields, and the individual container status arrays contain more detail about the pod's status. There are five possible phase values:\n\nPending: The pod has been accepted by the Kubernetes system, but one or more of the container images has not been created. This includes time before being scheduled as well as time spent downloading images over the network, which could take a while. Running: The pod has been bound to a node, and all of the containers have been created. At least one container is still running, or is in the process of starting or restarting. Succeeded: All containers in the pod have terminated in success, and will not be restarted. Failed: All containers in the pod have terminated, and at least one container has terminated in failure. The container either exited with non-zero status or was terminated by the system. Unknown: For some reason the state of the pod could not be obtained, typically due to an error in communicating with the host of the pod.\n\nMore info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-phase", "type": "string" }, "podIP": { - "description": "IP address allocated to the pod. Routable at least within the cluster. Empty if not yet allocated.", + "description": "podIP address allocated to the pod. Routable at least within the cluster. Empty if not yet allocated.", "type": "string" }, "podIPs": { @@ -8155,17 +10417,38 @@ "$ref": "#/definitions/v1.PodIP" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "ip" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "ip", "x-kubernetes-patch-strategy": "merge" }, "qosClass": { - "description": "The Quality of Service (QOS) classification assigned to the pod based on resource requirements See PodQOSClass type for available QOS classes More info: https://git.k8s.io/community/contributors/design-proposals/node/resource-qos.md\n\n", + "description": "The Quality of Service (QOS) classification assigned to the pod based on resource requirements See PodQOSClass type for available QOS classes More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-qos/#quality-of-service-classes", "type": "string" }, "reason": { "description": "A brief CamelCase message indicating details about why the pod is in this state. e.g. 'Evicted'", "type": "string" }, + "resize": { + "description": "Status of resources resize desired for pod's containers. It is empty if no resources resize is pending. Any changes to container resources will automatically set this to \"Proposed\" Deprecated: Resize status is moved to two pod conditions PodResizePending and PodResizeInProgress. PodResizePending will track states where the spec has been resized, but the Kubelet has not yet allocated the resources. PodResizeInProgress will track in-progress resizes, and should be present whenever allocated resources != acknowledged resources.", + "type": "string" + }, + "resourceClaimStatuses": { + "description": "Status of resource claims.", + "items": { + "$ref": "#/definitions/v1.PodResourceClaimStatus" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge,retainKeys" + }, "startTime": { "description": "RFC 3339 date and time at which the object was acknowledged by the Kubelet. This is before the Kubelet pulled the container image(s) for the pod.", "format": "date-time", @@ -8253,6 +10536,7 @@ "type": "object" }, "v1.PortStatus": { + "description": "PortStatus represents the error condition of a service port", "properties": { "error": { "description": "Error is to record the problem with the service port The format of the error shall comply with the following rules: - built-in error values shall be specified in this file and those shall use\n CamelCase names\n- cloud provider specific error values must have names that comply with the\n format foo.example.com/CamelCase.", @@ -8264,7 +10548,7 @@ "type": "integer" }, "protocol": { - "description": "Protocol is the protocol of the service port of which status is recorded here The supported values are: \"TCP\", \"UDP\", \"SCTP\"\n\n", + "description": "Protocol is the protocol of the service port of which status is recorded here The supported values are: \"TCP\", \"UDP\", \"SCTP\"", "type": "string" } }, @@ -8319,7 +10603,7 @@ "properties": { "exec": { "$ref": "#/definitions/v1.ExecAction", - "description": "Exec specifies the action to take." + "description": "Exec specifies a command to execute in the container." }, "failureThreshold": { "description": "Minimum consecutive failures for the probe to be considered failed after having succeeded. Defaults to 3. Minimum value is 1.", @@ -8328,11 +10612,11 @@ }, "grpc": { "$ref": "#/definitions/v1.GRPCAction", - "description": "GRPC specifies an action involving a GRPC port. This is a beta field and requires enabling GRPCContainerProbe feature gate." + "description": "GRPC specifies a GRPC HealthCheckRequest." }, "httpGet": { "$ref": "#/definitions/v1.HTTPGetAction", - "description": "HTTPGet specifies the http request to perform." + "description": "HTTPGet specifies an HTTP GET request to perform." }, "initialDelaySeconds": { "description": "Number of seconds after the container has started before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", @@ -8351,7 +10635,7 @@ }, "tcpSocket": { "$ref": "#/definitions/v1.TCPSocketAction", - "description": "TCPSocket specifies an action involving a TCP port." + "description": "TCPSocket specifies a connection to a TCP port." }, "terminationGracePeriodSeconds": { "description": "Optional duration in seconds the pod needs to terminate gracefully upon probe failure. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this value overrides the value provided by the pod spec. Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut down). This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset.", @@ -8375,11 +10659,12 @@ "type": "integer" }, "sources": { - "description": "sources is the list of volume projections", + "description": "sources is the list of volume projections. Each entry in this list handles one source.", "items": { "$ref": "#/definitions/v1.VolumeProjection" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object" @@ -8438,7 +10723,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "pool": { "description": "pool is the rados pool name. Default is rbd. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it", @@ -8483,7 +10769,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "pool": { "description": "pool is the rados pool name. Default is rbd. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it", @@ -8630,7 +10917,7 @@ }, "template": { "$ref": "#/definitions/v1.PodTemplateSpec", - "description": "Template is the object that describes the pod that will be created if insufficient replicas are detected. This takes precedence over a TemplateRef. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#pod-template" + "description": "Template is the object that describes the pod that will be created if insufficient replicas are detected. This takes precedence over a TemplateRef. The only allowed template.spec.restartPolicy value is \"Always\". More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#pod-template" } }, "type": "object" @@ -8649,6 +10936,10 @@ "$ref": "#/definitions/v1.ReplicationControllerCondition" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "type", "x-kubernetes-patch-strategy": "merge" }, @@ -8668,7 +10959,7 @@ "type": "integer" }, "replicas": { - "description": "Replicas is the most recently oberved number of replicas. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#what-is-a-replicationcontroller", + "description": "Replicas is the most recently observed number of replicas. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#what-is-a-replicationcontroller", "format": "int32", "type": "integer" } @@ -8678,6 +10969,23 @@ ], "type": "object" }, + "core.v1.ResourceClaim": { + "description": "ResourceClaim references one entry in PodSpec.ResourceClaims.", + "properties": { + "name": { + "description": "Name must match the name of one entry in pod.spec.resourceClaims of the Pod where this field is used. It makes that resource available inside a container.", + "type": "string" + }, + "request": { + "description": "Request is the name chosen for a request in the referenced claim. If empty, everything from the claim is made available, otherwise only the result of this request.", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, "v1.ResourceFieldSelector": { "description": "ResourceFieldSelector represents container resources (cpu, memory) and their output format", "properties": { @@ -8700,6 +11008,23 @@ "type": "object", "x-kubernetes-map-type": "atomic" }, + "v1.ResourceHealth": { + "description": "ResourceHealth represents the health of a resource. It has the latest device health information. This is a part of KEP https://kep.k8s.io/4680.", + "properties": { + "health": { + "description": "Health of the resource. can be one of:\n - Healthy: operates as normal\n - Unhealthy: reported unhealthy. We consider this a temporary health issue\n since we do not have a mechanism today to distinguish\n temporary and permanent issues.\n - Unknown: The status cannot be determined.\n For example, Device Plugin got unregistered and hasn't been re-registered since.\n\nIn future we may want to introduce the PermanentlyUnhealthy Status.", + "type": "string" + }, + "resourceID": { + "description": "ResourceID is the unique identifier of the resource. See the ResourceID type for more information.", + "type": "string" + } + }, + "required": [ + "resourceID" + ], + "type": "object" + }, "v1.ResourceQuota": { "description": "ResourceQuota sets aggregate quota restrictions enforced per namespace", "properties": { @@ -8787,7 +11112,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object" @@ -8815,6 +11141,17 @@ "v1.ResourceRequirements": { "description": "ResourceRequirements describes the compute resource requirements.", "properties": { + "claims": { + "description": "Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container.\n\nThis field depends on the DynamicResourceAllocation feature gate.\n\nThis field is immutable. It can only be set for containers.", + "items": { + "$ref": "#/definitions/core.v1.ResourceClaim" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map" + }, "limits": { "additionalProperties": { "$ref": "#/definitions/resource.Quantity" @@ -8826,12 +11163,36 @@ "additionalProperties": { "$ref": "#/definitions/resource.Quantity" }, - "description": "Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/", + "description": "Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/", "type": "object" } }, "type": "object" }, + "v1.ResourceStatus": { + "description": "ResourceStatus represents the status of a single resource allocated to a Pod.", + "properties": { + "name": { + "description": "Name of the resource. Must be unique within the pod and in case of non-DRA resource, match one of the resources from the pod spec. For DRA resources, the value must be \"claim:/\". When this status is reported about a container, the \"claim_name\" and \"request\" must match one of the claims of this container.", + "type": "string" + }, + "resources": { + "description": "List of unique resources health. Each element in the list contains an unique resource ID and its health. At a minimum, for the lifetime of a Pod, resource ID must uniquely identify the resource allocated to the Pod on the Node. If other Pod on the same Node reports the status with the same resource ID, it must be the same resource they share. See ResourceID type definition for a specific format it has in various use cases.", + "items": { + "$ref": "#/definitions/v1.ResourceHealth" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "resourceID" + ], + "x-kubernetes-list-type": "map" + } + }, + "required": [ + "name" + ], + "type": "object" + }, "v1.SELinuxOptions": { "description": "SELinuxOptions are the labels to be applied to the container", "properties": { @@ -8964,7 +11325,8 @@ "items": { "$ref": "#/definitions/v1.ScopedResourceSelectorRequirement" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object", @@ -8974,11 +11336,11 @@ "description": "A scoped-resource selector requirement is a selector that contains values, a scope name, and an operator that relates the scope name and values.", "properties": { "operator": { - "description": "Represents a scope's relationship to a set of values. Valid operators are In, NotIn, Exists, DoesNotExist.\n\n", + "description": "Represents a scope's relationship to a set of values. Valid operators are In, NotIn, Exists, DoesNotExist.", "type": "string" }, "scopeName": { - "description": "The name of the scope that the selector applies to.\n\n", + "description": "The name of the scope that the selector applies to.", "type": "string" }, "values": { @@ -8986,7 +11348,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "required": [ @@ -8999,11 +11362,11 @@ "description": "SeccompProfile defines a pod/container's seccomp profile settings. Only one profile source may be set.", "properties": { "localhostProfile": { - "description": "localhostProfile indicates a profile defined in a file on the node should be used. The profile must be preconfigured on the node to work. Must be a descending path, relative to the kubelet's configured seccomp profile location. Must only be set if type is \"Localhost\".", + "description": "localhostProfile indicates a profile defined in a file on the node should be used. The profile must be preconfigured on the node to work. Must be a descending path, relative to the kubelet's configured seccomp profile location. Must be set if type is \"Localhost\". Must NOT be set for any other type.", "type": "string" }, "type": { - "description": "type indicates which kind of seccomp profile will be applied. Valid options are:\n\nLocalhost - a profile defined in a file on the node should be used. RuntimeDefault - the container runtime default profile should be used. Unconfined - no profile should be applied.\n\n", + "description": "type indicates which kind of seccomp profile will be applied. Valid options are:\n\nLocalhost - a profile defined in a file on the node should be used. RuntimeDefault - the container runtime default profile should be used. Unconfined - no profile should be applied.", "type": "string" } }, @@ -9072,7 +11435,7 @@ "description": "SecretEnvSource selects a Secret to populate the environment variables with.\n\nThe contents of the target Secret's Data field will represent the key-value pairs as environment variables.", "properties": { "name": { - "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "description": "Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", "type": "string" }, "optional": { @@ -9090,7 +11453,7 @@ "type": "string" }, "name": { - "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "description": "Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", "type": "string" }, "optional": { @@ -9147,10 +11510,11 @@ "items": { "$ref": "#/definitions/v1.KeyToPath" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "name": { - "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "description": "Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", "type": "string" }, "optional": { @@ -9188,7 +11552,8 @@ "items": { "$ref": "#/definitions/v1.KeyToPath" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "optional": { "description": "optional field specify whether the Secret or its keys must be defined", @@ -9208,6 +11573,10 @@ "description": "AllowPrivilegeEscalation controls whether a process can gain more privileges than its parent process. This bool directly controls if the no_new_privs flag will be set on the container process. AllowPrivilegeEscalation is true always when the container is: 1) run as Privileged 2) has CAP_SYS_ADMIN Note that this field cannot be set when spec.os.name is windows.", "type": "boolean" }, + "appArmorProfile": { + "$ref": "#/definitions/v1.AppArmorProfile", + "description": "appArmorProfile is the AppArmor options to use by this container. If set, this profile overrides the pod's appArmorProfile. Note that this field cannot be set when spec.os.name is windows." + }, "capabilities": { "$ref": "#/definitions/v1.Capabilities", "description": "The capabilities to add/drop when running containers. Defaults to the default set of capabilities granted by the container runtime. Note that this field cannot be set when spec.os.name is windows." @@ -9217,7 +11586,7 @@ "type": "boolean" }, "procMount": { - "description": "procMount denotes the type of proc mount to use for the containers. The default is DefaultProcMount which uses the container runtime defaults for readonly paths and masked paths. This requires the ProcMountType feature flag to be enabled. Note that this field cannot be set when spec.os.name is windows.", + "description": "procMount denotes the type of proc mount to use for the containers. The default value is Default which uses the container runtime defaults for readonly paths and masked paths. This requires the ProcMountType feature flag to be enabled. Note that this field cannot be set when spec.os.name is windows.", "type": "string" }, "readOnlyRootFilesystem": { @@ -9302,7 +11671,8 @@ "items": { "$ref": "#/definitions/v1.LocalObjectReference" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "kind": { "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", @@ -9313,11 +11683,15 @@ "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" }, "secrets": { - "description": "Secrets is a list of the secrets in the same namespace that pods running using this ServiceAccount are allowed to use. Pods are only limited to this list if this service account has a \"kubernetes.io/enforce-mountable-secrets\" annotation set to \"true\". This field should not be used to find auto-generated service account token secrets for use outside of pods. Instead, tokens can be requested directly using the TokenRequest API, or service account token secrets can be manually created. More info: https://kubernetes.io/docs/concepts/configuration/secret", + "description": "Secrets is a list of the secrets in the same namespace that pods running using this ServiceAccount are allowed to use. Pods are only limited to this list if this service account has a \"kubernetes.io/enforce-mountable-secrets\" annotation set to \"true\". The \"kubernetes.io/enforce-mountable-secrets\" annotation is deprecated since v1.32. Prefer separate namespaces to isolate access to mounted secrets. This field should not be used to find auto-generated service account token secrets for use outside of pods. Instead, tokens can be requested directly using the TokenRequest API, or service account token secrets can be manually created. More info: https://kubernetes.io/docs/concepts/configuration/secret", "items": { "$ref": "#/definitions/v1.ObjectReference" }, "type": "array", + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "name", "x-kubernetes-patch-strategy": "merge" } @@ -9427,7 +11801,7 @@ "description": "ServicePort contains information on service's port.", "properties": { "appProtocol": { - "description": "The application protocol for this port. This field follows standard Kubernetes label syntax. Un-prefixed names are reserved for IANA standard service names (as per RFC-6335 and https://www.iana.org/assignments/service-names). Non-standard protocols should use prefixed names such as mycompany.com/my-custom-protocol.", + "description": "The application protocol for this port. This is used as a hint for implementations to offer richer behavior for protocols that they understand. This field follows standard Kubernetes label syntax. Valid values are either:\n\n* Un-prefixed protocol names - reserved for IANA standard service names (as per RFC-6335 and https://www.iana.org/assignments/service-names).\n\n* Kubernetes-defined prefixed names:\n * 'kubernetes.io/h2c' - HTTP/2 prior knowledge over cleartext as described in https://www.rfc-editor.org/rfc/rfc9113.html#name-starting-http-2-with-prior-\n * 'kubernetes.io/ws' - WebSocket over cleartext as described in https://www.rfc-editor.org/rfc/rfc6455\n * 'kubernetes.io/wss' - WebSocket over TLS as described in https://www.rfc-editor.org/rfc/rfc6455\n\n* Other protocols should use implementation-defined prefixed names such as mycompany.com/my-custom-protocol.", "type": "string" }, "name": { @@ -9445,7 +11819,7 @@ "type": "integer" }, "protocol": { - "description": "The IP protocol for this port. Supports \"TCP\", \"UDP\", and \"SCTP\". Default is TCP.\n\n", + "description": "The IP protocol for this port. Supports \"TCP\", \"UDP\", and \"SCTP\". Default is TCP.", "type": "string" }, "targetPort": { @@ -9482,14 +11856,15 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "externalName": { "description": "externalName is the external reference that discovery mechanisms will return as an alias for this service (e.g. a DNS CNAME record). No proxying will be involved. Must be a lowercase RFC-1123 hostname (https://tools.ietf.org/html/rfc1123) and requires `type` to be \"ExternalName\".", "type": "string" }, "externalTrafficPolicy": { - "description": "externalTrafficPolicy describes how nodes distribute service traffic they receive on one of the Service's \"externally-facing\" addresses (NodePorts, ExternalIPs, and LoadBalancer IPs). If set to \"Local\", the proxy will configure the service in a way that assumes that external load balancers will take care of balancing the service traffic between nodes, and so each node will deliver traffic only to the node-local endpoints of the service, without masquerading the client source IP. (Traffic mistakenly sent to a node with no endpoints will be dropped.) The default value, \"Cluster\", uses the standard behavior of routing to all endpoints evenly (possibly modified by topology and other features). Note that traffic sent to an External IP or LoadBalancer IP from within the cluster will always get \"Cluster\" semantics, but clients sending to a NodePort from within the cluster may need to take traffic policy into account when picking a node.\n\n", + "description": "externalTrafficPolicy describes how nodes distribute service traffic they receive on one of the Service's \"externally-facing\" addresses (NodePorts, ExternalIPs, and LoadBalancer IPs). If set to \"Local\", the proxy will configure the service in a way that assumes that external load balancers will take care of balancing the service traffic between nodes, and so each node will deliver traffic only to the node-local endpoints of the service, without masquerading the client source IP. (Traffic mistakenly sent to a node with no endpoints will be dropped.) The default value, \"Cluster\", uses the standard behavior of routing to all endpoints evenly (possibly modified by topology and other features). Note that traffic sent to an External IP or LoadBalancer IP from within the cluster will always get \"Cluster\" semantics, but clients sending to a NodePort from within the cluster may need to take traffic policy into account when picking a node.", "type": "string" }, "healthCheckNodePort": { @@ -9518,7 +11893,7 @@ "type": "string" }, "loadBalancerIP": { - "description": "Only applies to Service Type: LoadBalancer. This feature depends on whether the underlying cloud-provider supports specifying the loadBalancerIP when a load balancer is created. This field will be ignored if the cloud-provider does not support the feature. Deprecated: This field was under-specified and its meaning varies across implementations, and it cannot support dual-stack. As of Kubernetes v1.24, users are encouraged to use implementation-specific annotations when available. This field may be removed in a future API version.", + "description": "Only applies to Service Type: LoadBalancer. This feature depends on whether the underlying cloud-provider supports specifying the loadBalancerIP when a load balancer is created. This field will be ignored if the cloud-provider does not support the feature. Deprecated: This field was under-specified and its meaning varies across implementations. Using it is non-portable and it may not support dual-stack. Users are encouraged to use implementation-specific annotations when available.", "type": "string" }, "loadBalancerSourceRanges": { @@ -9526,7 +11901,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "ports": { "description": "The list of ports that are exposed by this service. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies", @@ -9555,15 +11931,19 @@ "x-kubernetes-map-type": "atomic" }, "sessionAffinity": { - "description": "Supports \"ClientIP\" and \"None\". Used to maintain session affinity. Enable client IP based session affinity. Must be ClientIP or None. Defaults to None. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies\n\n", + "description": "Supports \"ClientIP\" and \"None\". Used to maintain session affinity. Enable client IP based session affinity. Must be ClientIP or None. Defaults to None. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies", "type": "string" }, "sessionAffinityConfig": { "$ref": "#/definitions/v1.SessionAffinityConfig", "description": "sessionAffinityConfig contains the configurations of session affinity." }, + "trafficDistribution": { + "description": "TrafficDistribution offers a way to express preferences for how traffic is distributed to Service endpoints. Implementations can use this field as a hint, but are not required to guarantee strict adherence. If the field is not set, the implementation will apply its default routing strategy. If set to \"PreferClose\", implementations should prioritize endpoints that are in the same zone.", + "type": "string" + }, "type": { - "description": "type determines how the Service is exposed. Defaults to ClusterIP. Valid options are ExternalName, ClusterIP, NodePort, and LoadBalancer. \"ClusterIP\" allocates a cluster-internal IP address for load-balancing to endpoints. Endpoints are determined by the selector or if that is not specified, by manual construction of an Endpoints object or EndpointSlice objects. If clusterIP is \"None\", no virtual IP is allocated and the endpoints are published as a set of endpoints rather than a virtual IP. \"NodePort\" builds on ClusterIP and allocates a port on every node which routes to the same endpoints as the clusterIP. \"LoadBalancer\" builds on NodePort and creates an external load-balancer (if supported in the current cloud) which routes to the same endpoints as the clusterIP. \"ExternalName\" aliases this service to the specified externalName. Several other fields do not apply to ExternalName services. More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types\n\n", + "description": "type determines how the Service is exposed. Defaults to ClusterIP. Valid options are ExternalName, ClusterIP, NodePort, and LoadBalancer. \"ClusterIP\" allocates a cluster-internal IP address for load-balancing to endpoints. Endpoints are determined by the selector or if that is not specified, by manual construction of an Endpoints object or EndpointSlice objects. If clusterIP is \"None\", no virtual IP is allocated and the endpoints are published as a set of endpoints rather than a virtual IP. \"NodePort\" builds on ClusterIP and allocates a port on every node which routes to the same endpoints as the clusterIP. \"LoadBalancer\" builds on NodePort and creates an external load-balancer (if supported in the current cloud) which routes to the same endpoints as the clusterIP. \"ExternalName\" aliases this service to the specified externalName. Several other fields do not apply to ExternalName services. More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types", "type": "string" } }, @@ -9602,6 +11982,20 @@ }, "type": "object" }, + "v1.SleepAction": { + "description": "SleepAction describes a \"sleep\" action.", + "properties": { + "seconds": { + "description": "Seconds is the number of seconds to sleep.", + "format": "int64", + "type": "integer" + } + }, + "required": [ + "seconds" + ], + "type": "object" + }, "v1.StorageOSPersistentVolumeSource": { "description": "Represents a StorageOS persistent volume resource.", "properties": { @@ -9693,7 +12087,7 @@ "description": "The node this Taint is attached to has the \"effect\" on any pod that does not tolerate the Taint.", "properties": { "effect": { - "description": "Required. The effect of the taint on pods that do not tolerate the taint. Valid effects are NoSchedule, PreferNoSchedule and NoExecute.\n\n", + "description": "Required. The effect of the taint on pods that do not tolerate the taint. Valid effects are NoSchedule, PreferNoSchedule and NoExecute.", "type": "string" }, "key": { @@ -9701,7 +12095,7 @@ "type": "string" }, "timeAdded": { - "description": "TimeAdded represents the time at which the taint was added. It is only written for NoExecute taints.", + "description": "TimeAdded represents the time at which the taint was added.", "format": "date-time", "type": "string" }, @@ -9720,7 +12114,7 @@ "description": "The pod this Toleration is attached to tolerates any taint that matches the triple using the matching operator .", "properties": { "effect": { - "description": "Effect indicates the taint effect to match. Empty means match all taint effects. When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute.\n\n", + "description": "Effect indicates the taint effect to match. Empty means match all taint effects. When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute.", "type": "string" }, "key": { @@ -9728,7 +12122,7 @@ "type": "string" }, "operator": { - "description": "Operator represents a key's relationship to the value. Valid operators are Exists and Equal. Defaults to Equal. Exists is equivalent to wildcard for value, so that a pod can tolerate all taints of a particular category.\n\n", + "description": "Operator represents a key's relationship to the value. Valid operators are Exists and Equal. Defaults to Equal. Exists is equivalent to wildcard for value, so that a pod can tolerate all taints of a particular category.", "type": "string" }, "tolerationSeconds": { @@ -9755,7 +12149,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "required": [ @@ -9772,7 +12167,8 @@ "items": { "$ref": "#/definitions/v1.TopologySelectorLabelRequirement" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object", @@ -9786,7 +12182,7 @@ "description": "LabelSelector is used to find matching pods. Pods that match this label selector are counted to determine the number of pods in their corresponding topology domain." }, "matchLabelKeys": { - "description": "MatchLabelKeys is a set of pod label keys to select the pods over which spreading will be calculated. The keys are used to lookup values from the incoming pod labels, those key-value labels are ANDed with labelSelector to select the group of existing pods over which spreading will be calculated for the incoming pod. Keys that don't exist in the incoming pod labels will be ignored. A null or empty list means only match against labelSelector.", + "description": "MatchLabelKeys is a set of pod label keys to select the pods over which spreading will be calculated. The keys are used to lookup values from the incoming pod labels, those key-value labels are ANDed with labelSelector to select the group of existing pods over which spreading will be calculated for the incoming pod. The same key is forbidden to exist in both MatchLabelKeys and LabelSelector. MatchLabelKeys cannot be set when LabelSelector isn't set. Keys that don't exist in the incoming pod labels will be ignored. A null or empty list means only match against labelSelector.\n\nThis is a beta field and requires the MatchLabelKeysInPodTopologySpread feature gate to be enabled (enabled by default).", "items": { "type": "string" }, @@ -9799,16 +12195,16 @@ "type": "integer" }, "minDomains": { - "description": "MinDomains indicates a minimum number of eligible domains. When the number of eligible domains with matching topology keys is less than minDomains, Pod Topology Spread treats \"global minimum\" as 0, and then the calculation of Skew is performed. And when the number of eligible domains with matching topology keys equals or greater than minDomains, this value has no effect on scheduling. As a result, when the number of eligible domains is less than minDomains, scheduler won't schedule more than maxSkew Pods to those domains. If value is nil, the constraint behaves as if MinDomains is equal to 1. Valid values are integers greater than 0. When value is not nil, WhenUnsatisfiable must be DoNotSchedule.\n\nFor example, in a 3-zone cluster, MaxSkew is set to 2, MinDomains is set to 5 and pods with the same labelSelector spread as 2/2/2: | zone1 | zone2 | zone3 | | P P | P P | P P | The number of domains is less than 5(MinDomains), so \"global minimum\" is treated as 0. In this situation, new pod with the same labelSelector cannot be scheduled, because computed skew will be 3(3 - 0) if new Pod is scheduled to any of the three zones, it will violate MaxSkew.\n\nThis is a beta field and requires the MinDomainsInPodTopologySpread feature gate to be enabled (enabled by default).", + "description": "MinDomains indicates a minimum number of eligible domains. When the number of eligible domains with matching topology keys is less than minDomains, Pod Topology Spread treats \"global minimum\" as 0, and then the calculation of Skew is performed. And when the number of eligible domains with matching topology keys equals or greater than minDomains, this value has no effect on scheduling. As a result, when the number of eligible domains is less than minDomains, scheduler won't schedule more than maxSkew Pods to those domains. If value is nil, the constraint behaves as if MinDomains is equal to 1. Valid values are integers greater than 0. When value is not nil, WhenUnsatisfiable must be DoNotSchedule.\n\nFor example, in a 3-zone cluster, MaxSkew is set to 2, MinDomains is set to 5 and pods with the same labelSelector spread as 2/2/2: | zone1 | zone2 | zone3 | | P P | P P | P P | The number of domains is less than 5(MinDomains), so \"global minimum\" is treated as 0. In this situation, new pod with the same labelSelector cannot be scheduled, because computed skew will be 3(3 - 0) if new Pod is scheduled to any of the three zones, it will violate MaxSkew.", "format": "int32", "type": "integer" }, "nodeAffinityPolicy": { - "description": "NodeAffinityPolicy indicates how we will treat Pod's nodeAffinity/nodeSelector when calculating pod topology spread skew. Options are: - Honor: only nodes matching nodeAffinity/nodeSelector are included in the calculations. - Ignore: nodeAffinity/nodeSelector are ignored. All nodes are included in the calculations.\n\nIf this value is nil, the behavior is equivalent to the Honor policy. This is a alpha-level feature enabled by the NodeInclusionPolicyInPodTopologySpread feature flag.", + "description": "NodeAffinityPolicy indicates how we will treat Pod's nodeAffinity/nodeSelector when calculating pod topology spread skew. Options are: - Honor: only nodes matching nodeAffinity/nodeSelector are included in the calculations. - Ignore: nodeAffinity/nodeSelector are ignored. All nodes are included in the calculations.\n\nIf this value is nil, the behavior is equivalent to the Honor policy.", "type": "string" }, "nodeTaintsPolicy": { - "description": "NodeTaintsPolicy indicates how we will treat node taints when calculating pod topology spread skew. Options are: - Honor: nodes without taints, along with tainted nodes for which the incoming pod has a toleration, are included. - Ignore: node taints are ignored. All nodes are included.\n\nIf this value is nil, the behavior is equivalent to the Ignore policy. This is a alpha-level feature enabled by the NodeInclusionPolicyInPodTopologySpread feature flag.", + "description": "NodeTaintsPolicy indicates how we will treat node taints when calculating pod topology spread skew. Options are: - Honor: nodes without taints, along with tainted nodes for which the incoming pod has a toleration, are included. - Ignore: node taints are ignored. All nodes are included.\n\nIf this value is nil, the behavior is equivalent to the Ignore policy.", "type": "string" }, "topologyKey": { @@ -9816,7 +12212,7 @@ "type": "string" }, "whenUnsatisfiable": { - "description": "WhenUnsatisfiable indicates how to deal with a pod if it doesn't satisfy the spread constraint. - DoNotSchedule (default) tells the scheduler not to schedule it. - ScheduleAnyway tells the scheduler to schedule the pod in any location,\n but giving higher precedence to topologies that would help reduce the\n skew.\nA constraint is considered \"Unsatisfiable\" for an incoming pod if and only if every possible node assignment for that pod would violate \"MaxSkew\" on some topology. For example, in a 3-zone cluster, MaxSkew is set to 1, and pods with the same labelSelector spread as 3/1/1: | zone1 | zone2 | zone3 | | P P P | P | P | If WhenUnsatisfiable is set to DoNotSchedule, incoming pod can only be scheduled to zone2(zone3) to become 3/2/1(3/1/2) as ActualSkew(2-1) on zone2(zone3) satisfies MaxSkew(1). In other words, the cluster can still be imbalanced, but scheduler won't make it *more* imbalanced. It's a required field.\n\n", + "description": "WhenUnsatisfiable indicates how to deal with a pod if it doesn't satisfy the spread constraint. - DoNotSchedule (default) tells the scheduler not to schedule it. - ScheduleAnyway tells the scheduler to schedule the pod in any location,\n but giving higher precedence to topologies that would help reduce the\n skew.\nA constraint is considered \"Unsatisfiable\" for an incoming pod if and only if every possible node assignment for that pod would violate \"MaxSkew\" on some topology. For example, in a 3-zone cluster, MaxSkew is set to 1, and pods with the same labelSelector spread as 3/1/1: | zone1 | zone2 | zone3 | | P P P | P | P | If WhenUnsatisfiable is set to DoNotSchedule, incoming pod can only be scheduled to zone2(zone3) to become 3/2/1(3/1/2) as ActualSkew(2-1) on zone2(zone3) satisfies MaxSkew(1). In other words, the cluster can still be imbalanced, but scheduler won't make it *more* imbalanced. It's a required field.", "type": "string" } }, @@ -9850,28 +12246,54 @@ "type": "object", "x-kubernetes-map-type": "atomic" }, + "v1.TypedObjectReference": { + "description": "TypedObjectReference contains enough information to let you locate the typed referenced object", + "properties": { + "apiGroup": { + "description": "APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required.", + "type": "string" + }, + "kind": { + "description": "Kind is the type of resource being referenced", + "type": "string" + }, + "name": { + "description": "Name is the name of resource being referenced", + "type": "string" + }, + "namespace": { + "description": "Namespace is the namespace of resource being referenced Note that when a namespace is specified, a gateway.networking.k8s.io/ReferenceGrant object is required in the referent namespace to allow that namespace's owner to accept the reference. See the ReferenceGrant documentation for details. (Alpha) This field requires the CrossNamespaceVolumeDataSource feature gate to be enabled.", + "type": "string" + } + }, + "required": [ + "kind", + "name" + ], + "type": "object" + }, "v1.Volume": { "description": "Volume represents a named volume in a pod that may be accessed by any container in the pod.", "properties": { "awsElasticBlockStore": { "$ref": "#/definitions/v1.AWSElasticBlockStoreVolumeSource", - "description": "awsElasticBlockStore represents an AWS Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore" + "description": "awsElasticBlockStore represents an AWS Disk resource that is attached to a kubelet's host machine and then exposed to the pod. Deprecated: AWSElasticBlockStore is deprecated. All operations for the in-tree awsElasticBlockStore type are redirected to the ebs.csi.aws.com CSI driver. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore" }, "azureDisk": { "$ref": "#/definitions/v1.AzureDiskVolumeSource", - "description": "azureDisk represents an Azure Data Disk mount on the host and bind mount to the pod." + "description": "azureDisk represents an Azure Data Disk mount on the host and bind mount to the pod. Deprecated: AzureDisk is deprecated. All operations for the in-tree azureDisk type are redirected to the disk.csi.azure.com CSI driver." }, "azureFile": { "$ref": "#/definitions/v1.AzureFileVolumeSource", - "description": "azureFile represents an Azure File Service mount on the host and bind mount to the pod." + "description": "azureFile represents an Azure File Service mount on the host and bind mount to the pod. Deprecated: AzureFile is deprecated. All operations for the in-tree azureFile type are redirected to the file.csi.azure.com CSI driver." }, "cephfs": { "$ref": "#/definitions/v1.CephFSVolumeSource", - "description": "cephFS represents a Ceph FS mount on the host that shares a pod's lifetime" + "description": "cephFS represents a Ceph FS mount on the host that shares a pod's lifetime. Deprecated: CephFS is deprecated and the in-tree cephfs type is no longer supported." }, "cinder": { "$ref": "#/definitions/v1.CinderVolumeSource", - "description": "cinder represents a cinder volume attached and mounted on kubelets host machine. More info: https://examples.k8s.io/mysql-cinder-pd/README.md" + "description": "cinder represents a cinder volume attached and mounted on kubelets host machine. Deprecated: Cinder is deprecated. All operations for the in-tree cinder type are redirected to the cinder.csi.openstack.org CSI driver. More info: https://examples.k8s.io/mysql-cinder-pd/README.md" }, "configMap": { "$ref": "#/definitions/v1.ConfigMapVolumeSource", @@ -9879,7 +12301,7 @@ }, "csi": { "$ref": "#/definitions/v1.CSIVolumeSource", - "description": "csi (Container Storage Interface) represents ephemeral storage that is handled by certain external CSI drivers (Beta feature)." + "description": "csi (Container Storage Interface) represents ephemeral storage that is handled by certain external CSI drivers." }, "downwardAPI": { "$ref": "#/definitions/v1.DownwardAPIVolumeSource", @@ -9899,31 +12321,35 @@ }, "flexVolume": { "$ref": "#/definitions/v1.FlexVolumeSource", - "description": "flexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin." + "description": "flexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin. Deprecated: FlexVolume is deprecated. Consider using a CSIDriver instead." }, "flocker": { "$ref": "#/definitions/v1.FlockerVolumeSource", - "description": "flocker represents a Flocker volume attached to a kubelet's host machine. This depends on the Flocker control service being running" + "description": "flocker represents a Flocker volume attached to a kubelet's host machine. This depends on the Flocker control service being running. Deprecated: Flocker is deprecated and the in-tree flocker type is no longer supported." }, "gcePersistentDisk": { "$ref": "#/definitions/v1.GCEPersistentDiskVolumeSource", - "description": "gcePersistentDisk represents a GCE Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk" + "description": "gcePersistentDisk represents a GCE Disk resource that is attached to a kubelet's host machine and then exposed to the pod. Deprecated: GCEPersistentDisk is deprecated. All operations for the in-tree gcePersistentDisk type are redirected to the pd.csi.storage.gke.io CSI driver. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk" }, "gitRepo": { "$ref": "#/definitions/v1.GitRepoVolumeSource", - "description": "gitRepo represents a git repository at a particular revision. DEPRECATED: GitRepo is deprecated. To provision a container with a git repo, mount an EmptyDir into an InitContainer that clones the repo using git, then mount the EmptyDir into the Pod's container." + "description": "gitRepo represents a git repository at a particular revision. Deprecated: GitRepo is deprecated. To provision a container with a git repo, mount an EmptyDir into an InitContainer that clones the repo using git, then mount the EmptyDir into the Pod's container." }, "glusterfs": { "$ref": "#/definitions/v1.GlusterfsVolumeSource", - "description": "glusterfs represents a Glusterfs mount on the host that shares a pod's lifetime. More info: https://examples.k8s.io/volumes/glusterfs/README.md" + "description": "glusterfs represents a Glusterfs mount on the host that shares a pod's lifetime. Deprecated: Glusterfs is deprecated and the in-tree glusterfs type is no longer supported." }, "hostPath": { "$ref": "#/definitions/v1.HostPathVolumeSource", "description": "hostPath represents a pre-existing file or directory on the host machine that is directly exposed to the container. This is generally used for system agents or other privileged things that are allowed to see the host machine. Most containers will NOT need this. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath" }, + "image": { + "$ref": "#/definitions/v1.ImageVolumeSource", + "description": "image represents an OCI object (a container image or artifact) pulled and mounted on the kubelet's host machine. The volume is resolved at pod startup depending on which PullPolicy value is provided:\n\n- Always: the kubelet always attempts to pull the reference. Container creation will fail If the pull fails. - Never: the kubelet never pulls the reference and only uses a local image or artifact. Container creation will fail if the reference isn't present. - IfNotPresent: the kubelet pulls if the reference isn't already present on disk. Container creation will fail if the reference isn't present and the pull fails.\n\nThe volume gets re-resolved if the pod gets deleted and recreated, which means that new remote content will become available on pod recreation. A failure to resolve or pull the image during pod startup will block containers from starting and may add significant latency. Failures will be retried using normal volume backoff and will be reported on the pod reason and message. The types of objects that may be mounted by this volume are defined by the container runtime implementation on a host machine and at minimum must include all valid types supported by the container image field. The OCI object gets mounted in a single directory (spec.containers[*].volumeMounts.mountPath) by merging the manifest layers in the same way as for container images. The volume will be mounted read-only (ro) and non-executable files (noexec). Sub path mounts for containers are not supported (spec.containers[*].volumeMounts.subpath) before 1.33. The field spec.securityContext.fsGroupChangePolicy has no effect on this volume type." + }, "iscsi": { "$ref": "#/definitions/v1.ISCSIVolumeSource", - "description": "iscsi represents an ISCSI Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://examples.k8s.io/volumes/iscsi/README.md" + "description": "iscsi represents an ISCSI Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes/#iscsi" }, "name": { "description": "name of the volume. Must be a DNS_LABEL and unique within the pod. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", @@ -9939,11 +12365,11 @@ }, "photonPersistentDisk": { "$ref": "#/definitions/v1.PhotonPersistentDiskVolumeSource", - "description": "photonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine" + "description": "photonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine. Deprecated: PhotonPersistentDisk is deprecated and the in-tree photonPersistentDisk type is no longer supported." }, "portworxVolume": { "$ref": "#/definitions/v1.PortworxVolumeSource", - "description": "portworxVolume represents a portworx volume attached and mounted on kubelets host machine" + "description": "portworxVolume represents a portworx volume attached and mounted on kubelets host machine. Deprecated: PortworxVolume is deprecated. All operations for the in-tree portworxVolume type are redirected to the pxd.portworx.com CSI driver when the CSIMigrationPortworx feature-gate is on." }, "projected": { "$ref": "#/definitions/v1.ProjectedVolumeSource", @@ -9951,15 +12377,15 @@ }, "quobyte": { "$ref": "#/definitions/v1.QuobyteVolumeSource", - "description": "quobyte represents a Quobyte mount on the host that shares a pod's lifetime" + "description": "quobyte represents a Quobyte mount on the host that shares a pod's lifetime. Deprecated: Quobyte is deprecated and the in-tree quobyte type is no longer supported." }, "rbd": { "$ref": "#/definitions/v1.RBDVolumeSource", - "description": "rbd represents a Rados Block Device mount on the host that shares a pod's lifetime. More info: https://examples.k8s.io/volumes/rbd/README.md" + "description": "rbd represents a Rados Block Device mount on the host that shares a pod's lifetime. Deprecated: RBD is deprecated and the in-tree rbd type is no longer supported." }, "scaleIO": { "$ref": "#/definitions/v1.ScaleIOVolumeSource", - "description": "scaleIO represents a ScaleIO persistent volume attached and mounted on Kubernetes nodes." + "description": "scaleIO represents a ScaleIO persistent volume attached and mounted on Kubernetes nodes. Deprecated: ScaleIO is deprecated and the in-tree scaleIO type is no longer supported." }, "secret": { "$ref": "#/definitions/v1.SecretVolumeSource", @@ -9967,11 +12393,11 @@ }, "storageos": { "$ref": "#/definitions/v1.StorageOSVolumeSource", - "description": "storageOS represents a StorageOS volume attached and mounted on Kubernetes nodes." + "description": "storageOS represents a StorageOS volume attached and mounted on Kubernetes nodes. Deprecated: StorageOS is deprecated and the in-tree storageos type is no longer supported." }, "vsphereVolume": { "$ref": "#/definitions/v1.VsphereVirtualDiskVolumeSource", - "description": "vsphereVolume represents a vSphere volume attached and mounted on kubelets host machine" + "description": "vsphereVolume represents a vSphere volume attached and mounted on kubelets host machine. Deprecated: VsphereVolume is deprecated. All operations for the in-tree vsphereVolume type are redirected to the csi.vsphere.vmware.com CSI driver." } }, "required": [ @@ -10005,7 +12431,7 @@ "type": "string" }, "mountPropagation": { - "description": "mountPropagation determines how mounts are propagated from the host to container and the other way around. When not set, MountPropagationNone is used. This field is beta in 1.10.", + "description": "mountPropagation determines how mounts are propagated from the host to container and the other way around. When not set, MountPropagationNone is used. This field is beta in 1.10. When RecursiveReadOnly is set to IfPossible or to Enabled, MountPropagation must be None or unspecified (which defaults to None).", "type": "string" }, "name": { @@ -10016,6 +12442,10 @@ "description": "Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.", "type": "boolean" }, + "recursiveReadOnly": { + "description": "RecursiveReadOnly specifies whether read-only mounts should be handled recursively.\n\nIf ReadOnly is false, this field has no meaning and must be unspecified.\n\nIf ReadOnly is true, and this field is set to Disabled, the mount is not made recursively read-only. If this field is set to IfPossible, the mount is made recursively read-only, if it is supported by the container runtime. If this field is set to Enabled, the mount is made recursively read-only if it is supported by the container runtime, otherwise the pod will not be started and an error will be generated to indicate the reason.\n\nIf this field is set to IfPossible or Enabled, MountPropagation must be set to None (or be unspecified, which defaults to None).\n\nIf this field is not specified, it is treated as an equivalent of Disabled.", + "type": "string" + }, "subPath": { "description": "Path within the volume from which the container's volume should be mounted. Defaults to \"\" (volume's root).", "type": "string" @@ -10031,6 +12461,32 @@ ], "type": "object" }, + "v1.VolumeMountStatus": { + "description": "VolumeMountStatus shows status of volume mounts.", + "properties": { + "mountPath": { + "description": "MountPath corresponds to the original VolumeMount.", + "type": "string" + }, + "name": { + "description": "Name corresponds to the name of the original VolumeMount.", + "type": "string" + }, + "readOnly": { + "description": "ReadOnly corresponds to the original VolumeMount.", + "type": "boolean" + }, + "recursiveReadOnly": { + "description": "RecursiveReadOnly must be set to Disabled, Enabled, or unspecified (for non-readonly mounts). An IfPossible value in the original VolumeMount must be translated to Disabled or Enabled, depending on the mount result.", + "type": "string" + } + }, + "required": [ + "name", + "mountPath" + ], + "type": "object" + }, "v1.VolumeNodeAffinity": { "description": "VolumeNodeAffinity defines constraints that limit what nodes this volume can be accessed from.", "properties": { @@ -10042,8 +12498,12 @@ "type": "object" }, "v1.VolumeProjection": { - "description": "Projection that may be projected along with other supported volume types", + "description": "Projection that may be projected along with other supported volume types. Exactly one of these fields must be set.", "properties": { + "clusterTrustBundle": { + "$ref": "#/definitions/v1.ClusterTrustBundleProjection", + "description": "ClusterTrustBundle allows a pod to access the `.spec.trustBundle` field of ClusterTrustBundle objects in an auto-updating file.\n\nAlpha, gated by the ClusterTrustBundleProjection feature gate.\n\nClusterTrustBundle objects can either be selected by name, or by the combination of signer name and a label selector.\n\nKubelet performs aggressive normalization of the PEM contents written into the pod filesystem. Esoteric PEM features such as inter-block comments and block headers are stripped. Certificates are deduplicated. The ordering of certificates within the file is arbitrary, and Kubelet may change the order over time." + }, "configMap": { "$ref": "#/definitions/v1.ConfigMapProjection", "description": "configMap information about the configMap data to project" @@ -10052,6 +12512,10 @@ "$ref": "#/definitions/v1.DownwardAPIProjection", "description": "downwardAPI information about the downwardAPI data to project" }, + "podCertificate": { + "$ref": "#/definitions/v1.PodCertificateProjection", + "description": "Projects an auto-rotating credential bundle (private key and certificate chain) that the pod can use either as a TLS client or server.\n\nKubelet generates a private key and uses it to send a PodCertificateRequest to the named signer. Once the signer approves the request and issues a certificate chain, Kubelet writes the key and certificate chain to the pod filesystem. The pod does not start until certificates have been issued for each podCertificate projected volume source in its spec.\n\nKubelet will begin trying to rotate the certificate at the time indicated by the signer using the PodCertificateRequest.Status.BeginRefreshAt timestamp.\n\nKubelet can write a single file, indicated by the credentialBundlePath field, or separate files, indicated by the keyPath and certificateChainPath fields.\n\nThe credential bundle is a single file in PEM format. The first PEM entry is the private key (in PKCS#8 format), and the remaining PEM entries are the certificate chain issued by the signer (typically, signers will return their certificate chain in leaf-to-root order).\n\nPrefer using the credential bundle format, since your application code can read it atomically. If you use keyPath and certificateChainPath, your application must make two separate file reads. If these coincide with a certificate rotation, it is possible that the private key and leaf certificate you read may not correspond to each other. Your application will need to check for this condition, and re-read until they are consistent.\n\nThe named signer controls chooses the format of the certificate it issues; consult the signer implementation's documentation to learn how to use the certificates it issues." + }, "secret": { "$ref": "#/definitions/v1.SecretProjection", "description": "secret information about the secret data to project" @@ -10063,6 +12527,26 @@ }, "type": "object" }, + "v1.VolumeResourceRequirements": { + "description": "VolumeResourceRequirements describes the storage resource requirements for a volume.", + "properties": { + "limits": { + "additionalProperties": { + "$ref": "#/definitions/resource.Quantity" + }, + "description": "Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/", + "type": "object" + }, + "requests": { + "additionalProperties": { + "$ref": "#/definitions/resource.Quantity" + }, + "description": "Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/", + "type": "object" + } + }, + "type": "object" + }, "v1.VsphereVirtualDiskVolumeSource": { "description": "Represents a vSphere volume resource.", "properties": { @@ -10119,7 +12603,7 @@ "type": "string" }, "hostProcess": { - "description": "HostProcess determines if a container should be run as a 'Host Process' container. This field is alpha-level and will only be honored by components that enable the WindowsHostProcessContainers feature flag. Setting this field without the feature flag will result in errors when validating the Pod. All of a Pod's containers must have the same effective HostProcess value (it is not allowed to have a mix of HostProcess containers and non-HostProcess containers). In addition, if HostProcess is true then HostNetwork must also be set to true.", + "description": "HostProcess determines if a container should be run as a 'Host Process' container. All of a Pod's containers must have the same effective HostProcess value (it is not allowed to have a mix of HostProcess containers and non-HostProcess containers). In addition, if HostProcess is true then HostNetwork must also be set to true.", "type": "boolean" }, "runAsUserName": { @@ -10133,7 +12617,7 @@ "description": "Endpoint represents a single logical \"backend\" implementing a service.", "properties": { "addresses": { - "description": "addresses of this endpoint. The contents of this field are interpreted according to the corresponding EndpointSlice addressType field. Consumers must handle different types of addresses in the context of their own capabilities. This must contain at least one address but no more than 100. These are all assumed to be fungible and clients may choose to only use the first element. Refer to: https://issue.k8s.io/106267", + "description": "addresses of this endpoint. For EndpointSlices of addressType \"IPv4\" or \"IPv6\", the values are IP addresses in canonical form. The syntax and semantics of other addressType values are not defined. This must contain at least one address but no more than 100. EndpointSlices generated by the EndpointSlice controller will always have exactly 1 address. No semantics are defined for additional addresses beyond the first, and kube-proxy does not look at them.", "items": { "type": "string" }, @@ -10181,15 +12665,15 @@ "description": "EndpointConditions represents the current condition of an endpoint.", "properties": { "ready": { - "description": "ready indicates that this endpoint is prepared to receive traffic, according to whatever system is managing the endpoint. A nil value indicates an unknown state. In most cases consumers should interpret this unknown state as ready. For compatibility reasons, ready should never be \"true\" for terminating endpoints.", + "description": "ready indicates that this endpoint is ready to receive traffic, according to whatever system is managing the endpoint. A nil value should be interpreted as \"true\". In general, an endpoint should be marked ready if it is serving and not terminating, though this can be overridden in some cases, such as when the associated Service has set the publishNotReadyAddresses flag.", "type": "boolean" }, "serving": { - "description": "serving is identical to ready except that it is set regardless of the terminating state of endpoints. This condition should be set to true for a ready endpoint that is terminating. If nil, consumers should defer to the ready condition. This field can be enabled with the EndpointSliceTerminatingCondition feature gate.", + "description": "serving indicates that this endpoint is able to receive traffic, according to whatever system is managing the endpoint. For endpoints backed by pods, the EndpointSlice controller will mark the endpoint as serving if the pod's Ready condition is True. A nil value should be interpreted as \"true\".", "type": "boolean" }, "terminating": { - "description": "terminating indicates that this endpoint is terminating. A nil value indicates an unknown state. Consumers should interpret this unknown state to mean that the endpoint is not terminating. This field can be enabled with the EndpointSliceTerminatingCondition feature gate.", + "description": "terminating indicates that this endpoint is terminating. A nil value should be interpreted as \"false\".", "type": "boolean" } }, @@ -10198,8 +12682,16 @@ "v1.EndpointHints": { "description": "EndpointHints provides hints describing how an endpoint should be consumed.", "properties": { + "forNodes": { + "description": "forNodes indicates the node(s) this endpoint should be consumed by when using topology aware routing. May contain a maximum of 8 entries. This is an Alpha feature and is only used when the PreferSameTrafficDistribution feature gate is enabled.", + "items": { + "$ref": "#/definitions/v1.ForNode" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, "forZones": { - "description": "forZones indicates the zone(s) this endpoint should be consumed by to enable topology aware routing.", + "description": "forZones indicates the zone(s) this endpoint should be consumed by when using topology aware routing. May contain a maximum of 8 entries.", "items": { "$ref": "#/definitions/v1.ForZone" }, @@ -10213,20 +12705,20 @@ "description": "EndpointPort represents a Port used by an EndpointSlice", "properties": { "appProtocol": { - "description": "The application protocol for this port. This field follows standard Kubernetes label syntax. Un-prefixed names are reserved for IANA standard service names (as per RFC-6335 and https://www.iana.org/assignments/service-names). Non-standard protocols should use prefixed names such as mycompany.com/my-custom-protocol.", + "description": "The application protocol for this port. This is used as a hint for implementations to offer richer behavior for protocols that they understand. This field follows standard Kubernetes label syntax. Valid values are either:\n\n* Un-prefixed protocol names - reserved for IANA standard service names (as per RFC-6335 and https://www.iana.org/assignments/service-names).\n\n* Kubernetes-defined prefixed names:\n * 'kubernetes.io/h2c' - HTTP/2 prior knowledge over cleartext as described in https://www.rfc-editor.org/rfc/rfc9113.html#name-starting-http-2-with-prior-\n * 'kubernetes.io/ws' - WebSocket over cleartext as described in https://www.rfc-editor.org/rfc/rfc6455\n * 'kubernetes.io/wss' - WebSocket over TLS as described in https://www.rfc-editor.org/rfc/rfc6455\n\n* Other protocols should use implementation-defined prefixed names such as mycompany.com/my-custom-protocol.", "type": "string" }, "name": { - "description": "The name of this port. All ports in an EndpointSlice must have a unique name. If the EndpointSlice is dervied from a Kubernetes service, this corresponds to the Service.ports[].name. Name must either be an empty string or pass DNS_LABEL validation: * must be no more than 63 characters long. * must consist of lower case alphanumeric characters or '-'. * must start and end with an alphanumeric character. Default is empty string.", + "description": "name represents the name of this port. All ports in an EndpointSlice must have a unique name. If the EndpointSlice is derived from a Kubernetes service, this corresponds to the Service.ports[].name. Name must either be an empty string or pass DNS_LABEL validation: * must be no more than 63 characters long. * must consist of lower case alphanumeric characters or '-'. * must start and end with an alphanumeric character. Default is empty string.", "type": "string" }, "port": { - "description": "The port number of the endpoint. If this is not specified, ports are not restricted and must be interpreted in the context of the specific consumer.", + "description": "port represents the port number of the endpoint. If the EndpointSlice is derived from a Kubernetes service, this must be set to the service's target port. EndpointSlices used for other purposes may have a nil port.", "format": "int32", "type": "integer" }, "protocol": { - "description": "The IP protocol for this port. Must be UDP, TCP, or SCTP. Default is TCP.", + "description": "protocol represents the IP protocol for this port. Must be UDP, TCP, or SCTP. Default is TCP.", "type": "string" } }, @@ -10234,10 +12726,10 @@ "x-kubernetes-map-type": "atomic" }, "v1.EndpointSlice": { - "description": "EndpointSlice represents a subset of the endpoints that implement a service. For a given service there may be multiple EndpointSlice objects, selected by labels, which must be joined to produce the full set of endpoints.", + "description": "EndpointSlice represents a set of service endpoints. Most EndpointSlices are created by the EndpointSlice controller to represent the Pods selected by Service objects. For a given service there may be multiple EndpointSlice objects which must be joined to produce the full set of endpoints; you can find all of the slices for a given service by listing EndpointSlices in the service's namespace whose `kubernetes.io/service-name` label contains the service's name.", "properties": { "addressType": { - "description": "addressType specifies the type of address carried by this EndpointSlice. All addresses in this slice must be the same type. This field is immutable after creation. The following address types are currently supported: * IPv4: Represents an IPv4 Address. * IPv6: Represents an IPv6 Address. * FQDN: Represents a Fully Qualified Domain Name.\n\n", + "description": "addressType specifies the type of address carried by this EndpointSlice. All addresses in this slice must be the same type. This field is immutable after creation. The following address types are currently supported: * IPv4: Represents an IPv4 Address. * IPv6: Represents an IPv6 Address. * FQDN: Represents a Fully Qualified Domain Name. (Deprecated) The EndpointSlice controller only generates, and kube-proxy only processes, slices of addressType \"IPv4\" and \"IPv6\". No semantics are defined for the \"FQDN\" type.", "type": "string" }, "apiVersion": { @@ -10261,7 +12753,7 @@ "description": "Standard object's metadata." }, "ports": { - "description": "ports specifies the list of network ports exposed by each endpoint in this slice. Each port must have a unique name. When ports is empty, it indicates that there are no defined ports. When a port is defined with a nil port value, it indicates \"all ports\". Each slice may include a maximum of 100 ports.", + "description": "ports specifies the list of network ports exposed by each endpoint in this slice. Each port must have a unique name. Each slice may include a maximum of 100 ports. Services always have at least 1 port, so EndpointSlices generated by the EndpointSlice controller will likewise always have at least 1 port. EndpointSlices used for other purposes may have an empty ports list.", "items": { "$ref": "#/definitions/discovery.v1.EndpointPort" }, @@ -10290,7 +12782,7 @@ "type": "string" }, "items": { - "description": "List of endpoint slices", + "description": "items is the list of endpoint slices", "items": { "$ref": "#/definitions/v1.EndpointSlice" }, @@ -10317,6 +12809,19 @@ } ] }, + "v1.ForNode": { + "description": "ForNode provides information about which nodes should consume this endpoint.", + "properties": { + "name": { + "description": "name represents the name of the node.", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, "v1.ForZone": { "description": "ForZone provides information about which zones should consume this endpoint.", "properties": { @@ -10473,7 +12978,23 @@ ], "type": "object" }, - "v1beta1.FlowDistinguisherMethod": { + "v1.ExemptPriorityLevelConfiguration": { + "description": "ExemptPriorityLevelConfiguration describes the configurable aspects of the handling of exempt requests. In the mandatory exempt configuration object the values in the fields here can be modified by authorized users, unlike the rest of the `spec`.", + "properties": { + "lendablePercent": { + "description": "`lendablePercent` prescribes the fraction of the level's NominalCL that can be borrowed by other priority levels. This value of this field must be between 0 and 100, inclusive, and it defaults to 0. The number of seats that other levels can borrow from this level, known as this level's LendableConcurrencyLimit (LendableCL), is defined as follows.\n\nLendableCL(i) = round( NominalCL(i) * lendablePercent(i)/100.0 )", + "format": "int32", + "type": "integer" + }, + "nominalConcurrencyShares": { + "description": "`nominalConcurrencyShares` (NCS) contributes to the computation of the NominalConcurrencyLimit (NominalCL) of this level. This is the number of execution seats nominally reserved for this priority level. This DOES NOT limit the dispatching from this priority level but affects the other priority levels through the borrowing mechanism. The server's concurrency limit (ServerCL) is divided among all the priority levels in proportion to their NCS values:\n\nNominalCL(i) = ceil( ServerCL * NCS(i) / sum_ncs ) sum_ncs = sum[priority level k] NCS(k)\n\nBigger numbers mean a larger nominal concurrency limit, at the expense of every other priority level. This field has a default value of zero.", + "format": "int32", + "type": "integer" + } + }, + "type": "object" + }, + "v1.FlowDistinguisherMethod": { "description": "FlowDistinguisherMethod specifies the method of a flow distinguisher.", "properties": { "type": { @@ -10486,7 +13007,7 @@ ], "type": "object" }, - "v1beta1.FlowSchema": { + "v1.FlowSchema": { "description": "FlowSchema defines the schema of a group of flows. Note that a flow is made up of a set of inbound API requests with similar attributes and is identified by a pair of strings: the name of the FlowSchema and a \"flow distinguisher\".", "properties": { "apiVersion": { @@ -10502,11 +13023,11 @@ "description": "`metadata` is the standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" }, "spec": { - "$ref": "#/definitions/v1beta1.FlowSchemaSpec", + "$ref": "#/definitions/v1.FlowSchemaSpec", "description": "`spec` is the specification of the desired behavior of a FlowSchema. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" }, "status": { - "$ref": "#/definitions/v1beta1.FlowSchemaStatus", + "$ref": "#/definitions/v1.FlowSchemaStatus", "description": "`status` is the current status of a FlowSchema. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, @@ -10515,11 +13036,11 @@ { "group": "flowcontrol.apiserver.k8s.io", "kind": "FlowSchema", - "version": "v1beta1" + "version": "v1" } ] }, - "v1beta1.FlowSchemaCondition": { + "v1.FlowSchemaCondition": { "description": "FlowSchemaCondition describes conditions for a FlowSchema.", "properties": { "lastTransitionTime": { @@ -10546,7 +13067,7 @@ }, "type": "object" }, - "v1beta1.FlowSchemaList": { + "v1.FlowSchemaList": { "description": "FlowSchemaList is a list of FlowSchema objects.", "properties": { "apiVersion": { @@ -10556,7 +13077,7 @@ "items": { "description": "`items` is a list of FlowSchemas.", "items": { - "$ref": "#/definitions/v1beta1.FlowSchema" + "$ref": "#/definitions/v1.FlowSchema" }, "type": "array" }, @@ -10577,15 +13098,15 @@ { "group": "flowcontrol.apiserver.k8s.io", "kind": "FlowSchemaList", - "version": "v1beta1" + "version": "v1" } ] }, - "v1beta1.FlowSchemaSpec": { + "v1.FlowSchemaSpec": { "description": "FlowSchemaSpec describes how the FlowSchema's specification looks like.", "properties": { "distinguisherMethod": { - "$ref": "#/definitions/v1beta1.FlowDistinguisherMethod", + "$ref": "#/definitions/v1.FlowDistinguisherMethod", "description": "`distinguisherMethod` defines how to compute the flow distinguisher for requests that match this schema. `nil` specifies that the distinguisher is disabled and thus will always be the empty string." }, "matchingPrecedence": { @@ -10594,13 +13115,13 @@ "type": "integer" }, "priorityLevelConfiguration": { - "$ref": "#/definitions/v1beta1.PriorityLevelConfigurationReference", + "$ref": "#/definitions/v1.PriorityLevelConfigurationReference", "description": "`priorityLevelConfiguration` should reference a PriorityLevelConfiguration in the cluster. If the reference cannot be resolved, the FlowSchema will be ignored and marked as invalid in its status. Required." }, "rules": { "description": "`rules` describes which requests will match this flow schema. This FlowSchema matches a request if and only if at least one member of rules matches the request. if it is an empty slice, there will be no requests matching the FlowSchema.", "items": { - "$ref": "#/definitions/v1beta1.PolicyRulesWithSubjects" + "$ref": "#/definitions/v1.PolicyRulesWithSubjects" }, "type": "array", "x-kubernetes-list-type": "atomic" @@ -10611,24 +13132,26 @@ ], "type": "object" }, - "v1beta1.FlowSchemaStatus": { + "v1.FlowSchemaStatus": { "description": "FlowSchemaStatus represents the current state of a FlowSchema.", "properties": { "conditions": { "description": "`conditions` is a list of the current states of FlowSchema.", "items": { - "$ref": "#/definitions/v1beta1.FlowSchemaCondition" + "$ref": "#/definitions/v1.FlowSchemaCondition" }, "type": "array", "x-kubernetes-list-map-keys": [ "type" ], - "x-kubernetes-list-type": "map" + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" } }, "type": "object" }, - "v1beta1.GroupSubject": { + "v1.GroupSubject": { "description": "GroupSubject holds detailed information for group-kind subject.", "properties": { "name": { @@ -10641,11 +13164,11 @@ ], "type": "object" }, - "v1beta1.LimitResponse": { + "v1.LimitResponse": { "description": "LimitResponse defines how to handle requests that can not be executed right now.", "properties": { "queuing": { - "$ref": "#/definitions/v1beta1.QueuingConfiguration", + "$ref": "#/definitions/v1.QueuingConfiguration", "description": "`queuing` holds the configuration parameters for queuing. This field may be non-empty only if `type` is `\"Queue\"`." }, "type": { @@ -10666,22 +13189,32 @@ } ] }, - "v1beta1.LimitedPriorityLevelConfiguration": { + "v1.LimitedPriorityLevelConfiguration": { "description": "LimitedPriorityLevelConfiguration specifies how to handle requests that are subject to limits. It addresses two issues:\n - How are requests for this priority level limited?\n - What should be done with requests that exceed the limit?", "properties": { - "assuredConcurrencyShares": { - "description": "`assuredConcurrencyShares` (ACS) configures the execution limit, which is a limit on the number of requests of this priority level that may be exeucting at a given time. ACS must be a positive number. The server's concurrency limit (SCL) is divided among the concurrency-controlled priority levels in proportion to their assured concurrency shares. This produces the assured concurrency value (ACV) --- the number of requests that may be executing at a time --- for each such priority level:\n\n ACV(l) = ceil( SCL * ACS(l) / ( sum[priority levels k] ACS(k) ) )\n\nbigger numbers of ACS mean more reserved concurrent requests (at the expense of every other PL). This field has a default value of 30.", + "borrowingLimitPercent": { + "description": "`borrowingLimitPercent`, if present, configures a limit on how many seats this priority level can borrow from other priority levels. The limit is known as this level's BorrowingConcurrencyLimit (BorrowingCL) and is a limit on the total number of seats that this level may borrow at any one time. This field holds the ratio of that limit to the level's nominal concurrency limit. When this field is non-nil, it must hold a non-negative integer and the limit is calculated as follows.\n\nBorrowingCL(i) = round( NominalCL(i) * borrowingLimitPercent(i)/100.0 )\n\nThe value of this field can be more than 100, implying that this priority level can borrow a number of seats that is greater than its own nominal concurrency limit (NominalCL). When this field is left `nil`, the limit is effectively infinite.", + "format": "int32", + "type": "integer" + }, + "lendablePercent": { + "description": "`lendablePercent` prescribes the fraction of the level's NominalCL that can be borrowed by other priority levels. The value of this field must be between 0 and 100, inclusive, and it defaults to 0. The number of seats that other levels can borrow from this level, known as this level's LendableConcurrencyLimit (LendableCL), is defined as follows.\n\nLendableCL(i) = round( NominalCL(i) * lendablePercent(i)/100.0 )", "format": "int32", "type": "integer" }, "limitResponse": { - "$ref": "#/definitions/v1beta1.LimitResponse", + "$ref": "#/definitions/v1.LimitResponse", "description": "`limitResponse` indicates what to do with requests that can not be executed right now" + }, + "nominalConcurrencyShares": { + "description": "`nominalConcurrencyShares` (NCS) contributes to the computation of the NominalConcurrencyLimit (NominalCL) of this level. This is the number of execution seats available at this priority level. This is used both for requests dispatched from this priority level as well as requests dispatched from other priority levels borrowing seats from this level. The server's concurrency limit (ServerCL) is divided among the Limited priority levels in proportion to their NCS values:\n\nNominalCL(i) = ceil( ServerCL * NCS(i) / sum_ncs ) sum_ncs = sum[priority level k] NCS(k)\n\nBigger numbers mean a larger nominal concurrency limit, at the expense of every other priority level.\n\nIf not specified, this field defaults to a value of 30.\n\nSetting this field to zero supports the construction of a \"jail\" for this priority level that is used to hold some request(s)", + "format": "int32", + "type": "integer" } }, "type": "object" }, - "v1beta1.NonResourcePolicyRule": { + "v1.NonResourcePolicyRule": { "description": "NonResourcePolicyRule is a predicate that matches non-resource requests according to their verb and the target non-resource URL. A NonResourcePolicyRule matches a request if and only if both (a) at least one member of verbs matches the request and (b) at least one member of nonResourceURLs matches the request.", "properties": { "nonResourceURLs": { @@ -10707,13 +13240,13 @@ ], "type": "object" }, - "v1beta1.PolicyRulesWithSubjects": { + "v1.PolicyRulesWithSubjects": { "description": "PolicyRulesWithSubjects prescribes a test that applies to a request to an apiserver. The test considers the subject making the request, the verb being requested, and the resource to be acted upon. This PolicyRulesWithSubjects matches a request if and only if both (a) at least one member of subjects matches the request and (b) at least one member of resourceRules or nonResourceRules matches the request.", "properties": { "nonResourceRules": { "description": "`nonResourceRules` is a list of NonResourcePolicyRules that identify matching requests according to their verb and the target non-resource URL.", "items": { - "$ref": "#/definitions/v1beta1.NonResourcePolicyRule" + "$ref": "#/definitions/v1.NonResourcePolicyRule" }, "type": "array", "x-kubernetes-list-type": "atomic" @@ -10721,7 +13254,7 @@ "resourceRules": { "description": "`resourceRules` is a slice of ResourcePolicyRules that identify matching requests according to their verb and the target resource. At least one of `resourceRules` and `nonResourceRules` has to be non-empty.", "items": { - "$ref": "#/definitions/v1beta1.ResourcePolicyRule" + "$ref": "#/definitions/v1.ResourcePolicyRule" }, "type": "array", "x-kubernetes-list-type": "atomic" @@ -10729,7 +13262,7 @@ "subjects": { "description": "subjects is the list of normal user, serviceaccount, or group that this rule cares about. There must be at least one member in this slice. A slice that includes both the system:authenticated and system:unauthenticated user groups matches every request. Required.", "items": { - "$ref": "#/definitions/v1beta1.Subject" + "$ref": "#/definitions/flowcontrol.v1.Subject" }, "type": "array", "x-kubernetes-list-type": "atomic" @@ -10740,7 +13273,7 @@ ], "type": "object" }, - "v1beta1.PriorityLevelConfiguration": { + "v1.PriorityLevelConfiguration": { "description": "PriorityLevelConfiguration represents the configuration of a priority level.", "properties": { "apiVersion": { @@ -10756,11 +13289,11 @@ "description": "`metadata` is the standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" }, "spec": { - "$ref": "#/definitions/v1beta1.PriorityLevelConfigurationSpec", + "$ref": "#/definitions/v1.PriorityLevelConfigurationSpec", "description": "`spec` is the specification of the desired behavior of a \"request-priority\". More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" }, "status": { - "$ref": "#/definitions/v1beta1.PriorityLevelConfigurationStatus", + "$ref": "#/definitions/v1.PriorityLevelConfigurationStatus", "description": "`status` is the current status of a \"request-priority\". More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, @@ -10769,11 +13302,11 @@ { "group": "flowcontrol.apiserver.k8s.io", "kind": "PriorityLevelConfiguration", - "version": "v1beta1" + "version": "v1" } ] }, - "v1beta1.PriorityLevelConfigurationCondition": { + "v1.PriorityLevelConfigurationCondition": { "description": "PriorityLevelConfigurationCondition defines the condition of priority level.", "properties": { "lastTransitionTime": { @@ -10800,7 +13333,7 @@ }, "type": "object" }, - "v1beta1.PriorityLevelConfigurationList": { + "v1.PriorityLevelConfigurationList": { "description": "PriorityLevelConfigurationList is a list of PriorityLevelConfiguration objects.", "properties": { "apiVersion": { @@ -10810,7 +13343,7 @@ "items": { "description": "`items` is a list of request-priorities.", "items": { - "$ref": "#/definitions/v1beta1.PriorityLevelConfiguration" + "$ref": "#/definitions/v1.PriorityLevelConfiguration" }, "type": "array" }, @@ -10831,11 +13364,11 @@ { "group": "flowcontrol.apiserver.k8s.io", "kind": "PriorityLevelConfigurationList", - "version": "v1beta1" + "version": "v1" } ] }, - "v1beta1.PriorityLevelConfigurationReference": { + "v1.PriorityLevelConfigurationReference": { "description": "PriorityLevelConfigurationReference contains information that points to the \"request-priority\" being used.", "properties": { "name": { @@ -10848,11 +13381,15 @@ ], "type": "object" }, - "v1beta1.PriorityLevelConfigurationSpec": { + "v1.PriorityLevelConfigurationSpec": { "description": "PriorityLevelConfigurationSpec specifies the configuration of a priority level.", "properties": { + "exempt": { + "$ref": "#/definitions/v1.ExemptPriorityLevelConfiguration", + "description": "`exempt` specifies how requests are handled for an exempt priority level. This field MUST be empty if `type` is `\"Limited\"`. This field MAY be non-empty if `type` is `\"Exempt\"`. If empty and `type` is `\"Exempt\"` then the default values for `ExemptPriorityLevelConfiguration` apply." + }, "limited": { - "$ref": "#/definitions/v1beta1.LimitedPriorityLevelConfiguration", + "$ref": "#/definitions/v1.LimitedPriorityLevelConfiguration", "description": "`limited` specifies how requests are handled for a Limited priority level. This field must be non-empty if and only if `type` is `\"Limited\"`." }, "type": { @@ -10868,29 +13405,32 @@ { "discriminator": "type", "fields-to-discriminateBy": { + "exempt": "Exempt", "limited": "Limited" } } ] }, - "v1beta1.PriorityLevelConfigurationStatus": { + "v1.PriorityLevelConfigurationStatus": { "description": "PriorityLevelConfigurationStatus represents the current state of a \"request-priority\".", "properties": { "conditions": { "description": "`conditions` is the current state of \"request-priority\".", "items": { - "$ref": "#/definitions/v1beta1.PriorityLevelConfigurationCondition" + "$ref": "#/definitions/v1.PriorityLevelConfigurationCondition" }, "type": "array", "x-kubernetes-list-map-keys": [ "type" ], - "x-kubernetes-list-type": "map" + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" } }, "type": "object" }, - "v1beta1.QueuingConfiguration": { + "v1.QueuingConfiguration": { "description": "QueuingConfiguration holds the configuration parameters for queuing", "properties": { "handSize": { @@ -10911,7 +13451,7 @@ }, "type": "object" }, - "v1beta1.ResourcePolicyRule": { + "v1.ResourcePolicyRule": { "description": "ResourcePolicyRule is a predicate that matches some resource requests, testing the request's verb and the target resource. A ResourcePolicyRule matches a resource request if and only if: (a) at least one member of verbs matches the request, (b) at least one member of apiGroups matches the request, (c) at least one member of resources matches the request, and (d) either (d1) the request does not specify a namespace (i.e., `Namespace==\"\"`) and clusterScope is true or (d2) the request specifies a namespace and least one member of namespaces matches the request's namespace.", "properties": { "apiGroups": { @@ -10958,7 +13498,7 @@ ], "type": "object" }, - "v1beta1.ServiceAccountSubject": { + "v1.ServiceAccountSubject": { "description": "ServiceAccountSubject holds detailed information for service-account-kind subject.", "properties": { "name": { @@ -10976,11 +13516,11 @@ ], "type": "object" }, - "v1beta1.Subject": { + "flowcontrol.v1.Subject": { "description": "Subject matches the originator of a request, as identified by the request authentication system. There are three ways of matching an originator; by user, group, or service account.", "properties": { "group": { - "$ref": "#/definitions/v1beta1.GroupSubject", + "$ref": "#/definitions/v1.GroupSubject", "description": "`group` matches based on user group name." }, "kind": { @@ -10988,11 +13528,11 @@ "type": "string" }, "serviceAccount": { - "$ref": "#/definitions/v1beta1.ServiceAccountSubject", + "$ref": "#/definitions/v1.ServiceAccountSubject", "description": "`serviceAccount` matches ServiceAccounts." }, "user": { - "$ref": "#/definitions/v1beta1.UserSubject", + "$ref": "#/definitions/v1.UserSubject", "description": "`user` matches based on username." } }, @@ -11011,7 +13551,7 @@ } ] }, - "v1beta1.UserSubject": { + "v1.UserSubject": { "description": "UserSubject holds detailed information for user-kind subject.", "properties": { "name": { @@ -11024,21 +13564,47 @@ ], "type": "object" }, - "v1beta2.FlowDistinguisherMethod": { - "description": "FlowDistinguisherMethod specifies the method of a flow distinguisher.", + "v1.HTTPIngressPath": { + "description": "HTTPIngressPath associates a path with a backend. Incoming urls matching the path are forwarded to the backend.", "properties": { - "type": { - "description": "`type` is the type of flow distinguisher method The supported types are \"ByUser\" and \"ByNamespace\". Required.", + "backend": { + "$ref": "#/definitions/v1.IngressBackend", + "description": "backend defines the referenced service endpoint to which the traffic will be forwarded to." + }, + "path": { + "description": "path is matched against the path of an incoming request. Currently it can contain characters disallowed from the conventional \"path\" part of a URL as defined by RFC 3986. Paths must begin with a '/' and must be present when using PathType with value \"Exact\" or \"Prefix\".", + "type": "string" + }, + "pathType": { + "description": "pathType determines the interpretation of the path matching. PathType can be one of the following values: * Exact: Matches the URL path exactly. * Prefix: Matches based on a URL path prefix split by '/'. Matching is\n done on a path element by element basis. A path element refers is the\n list of labels in the path split by the '/' separator. A request is a\n match for path p if every p is an element-wise prefix of p of the\n request path. Note that if the last element of the path is a substring\n of the last element in request path, it is not a match (e.g. /foo/bar\n matches /foo/bar/baz, but does not match /foo/barbaz).\n* ImplementationSpecific: Interpretation of the Path matching is up to\n the IngressClass. Implementations can treat this as a separate PathType\n or treat it identically to Prefix or Exact path types.\nImplementations are required to support all path types.", "type": "string" } }, "required": [ - "type" + "pathType", + "backend" ], "type": "object" }, - "v1beta2.FlowSchema": { - "description": "FlowSchema defines the schema of a group of flows. Note that a flow is made up of a set of inbound API requests with similar attributes and is identified by a pair of strings: the name of the FlowSchema and a \"flow distinguisher\".", + "v1.HTTPIngressRuleValue": { + "description": "HTTPIngressRuleValue is a list of http selectors pointing to backends. In the example: http:///? -> backend where where parts of the url correspond to RFC 3986, this resource will be used to match against everything after the last '/' and before the first '?' or '#'.", + "properties": { + "paths": { + "description": "paths is a collection of paths that map requests to backends.", + "items": { + "$ref": "#/definitions/v1.HTTPIngressPath" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + } + }, + "required": [ + "paths" + ], + "type": "object" + }, + "v1.IPAddress": { + "description": "IPAddress represents a single IP of a single IP Family. The object is designed to be used by APIs that operate on IP addresses. The object is used by the Service core API for allocation of IP addresses. An IP address can be represented in different formats, to guarantee the uniqueness of the IP, the name of the object is the IP address in canonical format, four decimal digits separated by dots suppressing leading zeros for IPv4 and the representation defined by RFC 5952 for IPv6. Valid: 192.168.1.5 or 2001:db8::1 or 2001:db8:aaaa:bbbb:cccc:dddd:eeee:1 Invalid: 10.01.2.3 or 2001:db8:0:0:0::1", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", @@ -11050,64 +13616,33 @@ }, "metadata": { "$ref": "#/definitions/v1.ObjectMeta", - "description": "`metadata` is the standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" }, "spec": { - "$ref": "#/definitions/v1beta2.FlowSchemaSpec", - "description": "`spec` is the specification of the desired behavior of a FlowSchema. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" - }, - "status": { - "$ref": "#/definitions/v1beta2.FlowSchemaStatus", - "description": "`status` is the current status of a FlowSchema. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" + "$ref": "#/definitions/v1.IPAddressSpec", + "description": "spec is the desired state of the IPAddress. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "flowcontrol.apiserver.k8s.io", - "kind": "FlowSchema", - "version": "v1beta2" + "group": "networking.k8s.io", + "kind": "IPAddress", + "version": "v1" } ] }, - "v1beta2.FlowSchemaCondition": { - "description": "FlowSchemaCondition describes conditions for a FlowSchema.", - "properties": { - "lastTransitionTime": { - "description": "`lastTransitionTime` is the last time the condition transitioned from one status to another.", - "format": "date-time", - "type": "string" - }, - "message": { - "description": "`message` is a human-readable message indicating details about last transition.", - "type": "string" - }, - "reason": { - "description": "`reason` is a unique, one-word, CamelCase reason for the condition's last transition.", - "type": "string" - }, - "status": { - "description": "`status` is the status of the condition. Can be True, False, Unknown. Required.", - "type": "string" - }, - "type": { - "description": "`type` is the type of the condition. Required.", - "type": "string" - } - }, - "type": "object" - }, - "v1beta2.FlowSchemaList": { - "description": "FlowSchemaList is a list of FlowSchema objects.", + "v1.IPAddressList": { + "description": "IPAddressList contains a list of IPAddress.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, "items": { - "description": "`items` is a list of FlowSchemas.", + "description": "items is the list of IPAddresses.", "items": { - "$ref": "#/definitions/v1beta2.FlowSchema" + "$ref": "#/definitions/v1.IPAddress" }, "type": "array" }, @@ -11117,7 +13652,7 @@ }, "metadata": { "$ref": "#/definitions/v1.ListMeta", - "description": "`metadata` is the standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" } }, "required": [ @@ -11126,242 +13661,212 @@ "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "flowcontrol.apiserver.k8s.io", - "kind": "FlowSchemaList", - "version": "v1beta2" + "group": "networking.k8s.io", + "kind": "IPAddressList", + "version": "v1" } ] }, - "v1beta2.FlowSchemaSpec": { - "description": "FlowSchemaSpec describes how the FlowSchema's specification looks like.", + "v1.IPAddressSpec": { + "description": "IPAddressSpec describe the attributes in an IP Address.", "properties": { - "distinguisherMethod": { - "$ref": "#/definitions/v1beta2.FlowDistinguisherMethod", - "description": "`distinguisherMethod` defines how to compute the flow distinguisher for requests that match this schema. `nil` specifies that the distinguisher is disabled and thus will always be the empty string." - }, - "matchingPrecedence": { - "description": "`matchingPrecedence` is used to choose among the FlowSchemas that match a given request. The chosen FlowSchema is among those with the numerically lowest (which we take to be logically highest) MatchingPrecedence. Each MatchingPrecedence value must be ranged in [1,10000]. Note that if the precedence is not specified, it will be set to 1000 as default.", - "format": "int32", - "type": "integer" - }, - "priorityLevelConfiguration": { - "$ref": "#/definitions/v1beta2.PriorityLevelConfigurationReference", - "description": "`priorityLevelConfiguration` should reference a PriorityLevelConfiguration in the cluster. If the reference cannot be resolved, the FlowSchema will be ignored and marked as invalid in its status. Required." - }, - "rules": { - "description": "`rules` describes which requests will match this flow schema. This FlowSchema matches a request if and only if at least one member of rules matches the request. if it is an empty slice, there will be no requests matching the FlowSchema.", - "items": { - "$ref": "#/definitions/v1beta2.PolicyRulesWithSubjects" - }, - "type": "array", - "x-kubernetes-list-type": "atomic" + "parentRef": { + "$ref": "#/definitions/v1.ParentReference", + "description": "ParentRef references the resource that an IPAddress is attached to. An IPAddress must reference a parent object." } }, "required": [ - "priorityLevelConfiguration" + "parentRef" ], "type": "object" }, - "v1beta2.FlowSchemaStatus": { - "description": "FlowSchemaStatus represents the current state of a FlowSchema.", + "v1.IPBlock": { + "description": "IPBlock describes a particular CIDR (Ex. \"192.168.1.0/24\",\"2001:db8::/64\") that is allowed to the pods matched by a NetworkPolicySpec's podSelector. The except entry describes CIDRs that should not be included within this rule.", "properties": { - "conditions": { - "description": "`conditions` is a list of the current states of FlowSchema.", + "cidr": { + "description": "cidr is a string representing the IPBlock Valid examples are \"192.168.1.0/24\" or \"2001:db8::/64\"", + "type": "string" + }, + "except": { + "description": "except is a slice of CIDRs that should not be included within an IPBlock Valid examples are \"192.168.1.0/24\" or \"2001:db8::/64\" Except values will be rejected if they are outside the cidr range", "items": { - "$ref": "#/definitions/v1beta2.FlowSchemaCondition" + "type": "string" }, "type": "array", - "x-kubernetes-list-map-keys": [ - "type" - ], - "x-kubernetes-list-type": "map" - } - }, - "type": "object" - }, - "v1beta2.GroupSubject": { - "description": "GroupSubject holds detailed information for group-kind subject.", - "properties": { - "name": { - "description": "name is the user group that matches, or \"*\" to match all user groups. See https://github.com/kubernetes/apiserver/blob/master/pkg/authentication/user/user.go for some well-known group names. Required.", - "type": "string" + "x-kubernetes-list-type": "atomic" } }, "required": [ - "name" + "cidr" ], "type": "object" }, - "v1beta2.LimitResponse": { - "description": "LimitResponse defines how to handle requests that can not be executed right now.", + "v1.Ingress": { + "description": "Ingress is a collection of rules that allow inbound connections to reach the endpoints defined by a backend. An Ingress can be configured to give services externally-reachable urls, load balance traffic, terminate SSL, offer name based virtual hosting etc.", "properties": { - "queuing": { - "$ref": "#/definitions/v1beta2.QueuingConfiguration", - "description": "`queuing` holds the configuration parameters for queuing. This field may be non-empty only if `type` is `\"Queue\"`." + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" }, - "type": { - "description": "`type` is \"Queue\" or \"Reject\". \"Queue\" means that requests that can not be executed upon arrival are held in a queue until they can be executed or a queuing limit is reached. \"Reject\" means that requests that can not be executed upon arrival are rejected. Required.", + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", "type": "string" + }, + "metadata": { + "$ref": "#/definitions/v1.ObjectMeta", + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + }, + "spec": { + "$ref": "#/definitions/v1.IngressSpec", + "description": "spec is the desired state of the Ingress. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" + }, + "status": { + "$ref": "#/definitions/v1.IngressStatus", + "description": "status is the current state of the Ingress. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, - "required": [ - "type" - ], "type": "object", - "x-kubernetes-unions": [ + "x-kubernetes-group-version-kind": [ { - "discriminator": "type", - "fields-to-discriminateBy": { - "queuing": "Queuing" - } + "group": "networking.k8s.io", + "kind": "Ingress", + "version": "v1" } ] }, - "v1beta2.LimitedPriorityLevelConfiguration": { - "description": "LimitedPriorityLevelConfiguration specifies how to handle requests that are subject to limits. It addresses two issues:\n - How are requests for this priority level limited?\n - What should be done with requests that exceed the limit?", + "v1.IngressBackend": { + "description": "IngressBackend describes all endpoints for a given service and port.", "properties": { - "assuredConcurrencyShares": { - "description": "`assuredConcurrencyShares` (ACS) configures the execution limit, which is a limit on the number of requests of this priority level that may be exeucting at a given time. ACS must be a positive number. The server's concurrency limit (SCL) is divided among the concurrency-controlled priority levels in proportion to their assured concurrency shares. This produces the assured concurrency value (ACV) --- the number of requests that may be executing at a time --- for each such priority level:\n\n ACV(l) = ceil( SCL * ACS(l) / ( sum[priority levels k] ACS(k) ) )\n\nbigger numbers of ACS mean more reserved concurrent requests (at the expense of every other PL). This field has a default value of 30.", - "format": "int32", - "type": "integer" + "resource": { + "$ref": "#/definitions/v1.TypedLocalObjectReference", + "description": "resource is an ObjectRef to another Kubernetes resource in the namespace of the Ingress object. If resource is specified, a service.Name and service.Port must not be specified. This is a mutually exclusive setting with \"Service\"." }, - "limitResponse": { - "$ref": "#/definitions/v1beta2.LimitResponse", - "description": "`limitResponse` indicates what to do with requests that can not be executed right now" + "service": { + "$ref": "#/definitions/v1.IngressServiceBackend", + "description": "service references a service as a backend. This is a mutually exclusive setting with \"Resource\"." } }, "type": "object" }, - "v1beta2.NonResourcePolicyRule": { - "description": "NonResourcePolicyRule is a predicate that matches non-resource requests according to their verb and the target non-resource URL. A NonResourcePolicyRule matches a request if and only if both (a) at least one member of verbs matches the request and (b) at least one member of nonResourceURLs matches the request.", + "v1.IngressClass": { + "description": "IngressClass represents the class of the Ingress, referenced by the Ingress Spec. The `ingressclass.kubernetes.io/is-default-class` annotation can be used to indicate that an IngressClass should be considered default. When a single IngressClass resource has this annotation set to true, new Ingress resources without a class specified will be assigned this default class.", "properties": { - "nonResourceURLs": { - "description": "`nonResourceURLs` is a set of url prefixes that a user should have access to and may not be empty. For example:\n - \"/healthz\" is legal\n - \"/hea*\" is illegal\n - \"/hea\" is legal but matches nothing\n - \"/hea/*\" also matches nothing\n - \"/healthz/*\" matches all per-component health checks.\n\"*\" matches all non-resource urls. if it is present, it must be the only entry. Required.", - "items": { - "type": "string" - }, - "type": "array", - "x-kubernetes-list-type": "set" + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" }, - "verbs": { - "description": "`verbs` is a list of matching verbs and may not be empty. \"*\" matches all verbs. If it is present, it must be the only entry. Required.", - "items": { - "type": "string" - }, - "type": "array", - "x-kubernetes-list-type": "set" - } - }, - "required": [ - "verbs", - "nonResourceURLs" - ], - "type": "object" - }, - "v1beta2.PolicyRulesWithSubjects": { - "description": "PolicyRulesWithSubjects prescribes a test that applies to a request to an apiserver. The test considers the subject making the request, the verb being requested, and the resource to be acted upon. This PolicyRulesWithSubjects matches a request if and only if both (a) at least one member of subjects matches the request and (b) at least one member of resourceRules or nonResourceRules matches the request.", - "properties": { - "nonResourceRules": { - "description": "`nonResourceRules` is a list of NonResourcePolicyRules that identify matching requests according to their verb and the target non-resource URL.", - "items": { - "$ref": "#/definitions/v1beta2.NonResourcePolicyRule" - }, - "type": "array", - "x-kubernetes-list-type": "atomic" + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" }, - "resourceRules": { - "description": "`resourceRules` is a slice of ResourcePolicyRules that identify matching requests according to their verb and the target resource. At least one of `resourceRules` and `nonResourceRules` has to be non-empty.", - "items": { - "$ref": "#/definitions/v1beta2.ResourcePolicyRule" - }, - "type": "array", - "x-kubernetes-list-type": "atomic" + "metadata": { + "$ref": "#/definitions/v1.ObjectMeta", + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" }, - "subjects": { - "description": "subjects is the list of normal user, serviceaccount, or group that this rule cares about. There must be at least one member in this slice. A slice that includes both the system:authenticated and system:unauthenticated user groups matches every request. Required.", - "items": { - "$ref": "#/definitions/v1beta2.Subject" - }, - "type": "array", - "x-kubernetes-list-type": "atomic" + "spec": { + "$ref": "#/definitions/v1.IngressClassSpec", + "description": "spec is the desired state of the IngressClass. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, - "required": [ - "subjects" - ], - "type": "object" + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "networking.k8s.io", + "kind": "IngressClass", + "version": "v1" + } + ] }, - "v1beta2.PriorityLevelConfiguration": { - "description": "PriorityLevelConfiguration represents the configuration of a priority level.", + "v1.IngressClassList": { + "description": "IngressClassList is a collection of IngressClasses.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, + "items": { + "description": "items is the list of IngressClasses.", + "items": { + "$ref": "#/definitions/v1.IngressClass" + }, + "type": "array" + }, "kind": { "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", "type": "string" }, "metadata": { - "$ref": "#/definitions/v1.ObjectMeta", - "description": "`metadata` is the standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" - }, - "spec": { - "$ref": "#/definitions/v1beta2.PriorityLevelConfigurationSpec", - "description": "`spec` is the specification of the desired behavior of a \"request-priority\". More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" - }, - "status": { - "$ref": "#/definitions/v1beta2.PriorityLevelConfigurationStatus", - "description": "`status` is the current status of a \"request-priority\". More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" + "$ref": "#/definitions/v1.ListMeta", + "description": "Standard list metadata." } }, + "required": [ + "items" + ], "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "flowcontrol.apiserver.k8s.io", - "kind": "PriorityLevelConfiguration", - "version": "v1beta2" + "group": "networking.k8s.io", + "kind": "IngressClassList", + "version": "v1" } ] }, - "v1beta2.PriorityLevelConfigurationCondition": { - "description": "PriorityLevelConfigurationCondition defines the condition of priority level.", + "v1.IngressClassParametersReference": { + "description": "IngressClassParametersReference identifies an API object. This can be used to specify a cluster or namespace-scoped resource.", "properties": { - "lastTransitionTime": { - "description": "`lastTransitionTime` is the last time the condition transitioned from one status to another.", - "format": "date-time", + "apiGroup": { + "description": "apiGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required.", "type": "string" }, - "message": { - "description": "`message` is a human-readable message indicating details about last transition.", + "kind": { + "description": "kind is the type of resource being referenced.", "type": "string" }, - "reason": { - "description": "`reason` is a unique, one-word, CamelCase reason for the condition's last transition.", + "name": { + "description": "name is the name of resource being referenced.", "type": "string" }, - "status": { - "description": "`status` is the status of the condition. Can be True, False, Unknown. Required.", + "namespace": { + "description": "namespace is the namespace of the resource being referenced. This field is required when scope is set to \"Namespace\" and must be unset when scope is set to \"Cluster\".", "type": "string" }, - "type": { - "description": "`type` is the type of the condition. Required.", + "scope": { + "description": "scope represents if this refers to a cluster or namespace scoped resource. This may be set to \"Cluster\" (default) or \"Namespace\".", "type": "string" } }, + "required": [ + "kind", + "name" + ], "type": "object" }, - "v1beta2.PriorityLevelConfigurationList": { - "description": "PriorityLevelConfigurationList is a list of PriorityLevelConfiguration objects.", + "v1.IngressClassSpec": { + "description": "IngressClassSpec provides information about the class of an Ingress.", + "properties": { + "controller": { + "description": "controller refers to the name of the controller that should handle this class. This allows for different \"flavors\" that are controlled by the same controller. For example, you may have different parameters for the same implementing controller. This should be specified as a domain-prefixed path no more than 250 characters in length, e.g. \"acme.io/ingress-controller\". This field is immutable.", + "type": "string" + }, + "parameters": { + "$ref": "#/definitions/v1.IngressClassParametersReference", + "description": "parameters is a link to a custom resource containing additional configuration for the controller. This is optional if the controller does not require extra parameters." + } + }, + "type": "object" + }, + "v1.IngressList": { + "description": "IngressList is a collection of Ingress.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, "items": { - "description": "`items` is a list of request-priorities.", + "description": "items is the list of Ingress.", "items": { - "$ref": "#/definitions/v1beta2.PriorityLevelConfiguration" + "$ref": "#/definitions/v1.Ingress" }, "type": "array" }, @@ -11371,7 +13876,7 @@ }, "metadata": { "$ref": "#/definitions/v1.ListMeta", - "description": "`metadata` is the standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" } }, "required": [ @@ -11380,262 +13885,161 @@ "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "flowcontrol.apiserver.k8s.io", - "kind": "PriorityLevelConfigurationList", - "version": "v1beta2" + "group": "networking.k8s.io", + "kind": "IngressList", + "version": "v1" } ] }, - "v1beta2.PriorityLevelConfigurationReference": { - "description": "PriorityLevelConfigurationReference contains information that points to the \"request-priority\" being used.", + "v1.IngressLoadBalancerIngress": { + "description": "IngressLoadBalancerIngress represents the status of a load-balancer ingress point.", "properties": { - "name": { - "description": "`name` is the name of the priority level configuration being referenced Required.", + "hostname": { + "description": "hostname is set for load-balancer ingress points that are DNS based.", "type": "string" - } - }, - "required": [ - "name" - ], - "type": "object" - }, - "v1beta2.PriorityLevelConfigurationSpec": { - "description": "PriorityLevelConfigurationSpec specifies the configuration of a priority level.", - "properties": { - "limited": { - "$ref": "#/definitions/v1beta2.LimitedPriorityLevelConfiguration", - "description": "`limited` specifies how requests are handled for a Limited priority level. This field must be non-empty if and only if `type` is `\"Limited\"`." }, - "type": { - "description": "`type` indicates whether this priority level is subject to limitation on request execution. A value of `\"Exempt\"` means that requests of this priority level are not subject to a limit (and thus are never queued) and do not detract from the capacity made available to other priority levels. A value of `\"Limited\"` means that (a) requests of this priority level _are_ subject to limits and (b) some of the server's limited capacity is made available exclusively to this priority level. Required.", + "ip": { + "description": "ip is set for load-balancer ingress points that are IP based.", "type": "string" + }, + "ports": { + "description": "ports provides information about the ports exposed by this LoadBalancer.", + "items": { + "$ref": "#/definitions/v1.IngressPortStatus" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" } }, - "required": [ - "type" - ], - "type": "object", - "x-kubernetes-unions": [ - { - "discriminator": "type", - "fields-to-discriminateBy": { - "limited": "Limited" - } - } - ] + "type": "object" }, - "v1beta2.PriorityLevelConfigurationStatus": { - "description": "PriorityLevelConfigurationStatus represents the current state of a \"request-priority\".", + "v1.IngressLoadBalancerStatus": { + "description": "IngressLoadBalancerStatus represents the status of a load-balancer.", "properties": { - "conditions": { - "description": "`conditions` is the current state of \"request-priority\".", + "ingress": { + "description": "ingress is a list containing ingress points for the load-balancer.", "items": { - "$ref": "#/definitions/v1beta2.PriorityLevelConfigurationCondition" + "$ref": "#/definitions/v1.IngressLoadBalancerIngress" }, "type": "array", - "x-kubernetes-list-map-keys": [ - "type" - ], - "x-kubernetes-list-type": "map" + "x-kubernetes-list-type": "atomic" } }, "type": "object" }, - "v1beta2.QueuingConfiguration": { - "description": "QueuingConfiguration holds the configuration parameters for queuing", + "v1.IngressPortStatus": { + "description": "IngressPortStatus represents the error condition of a service port", "properties": { - "handSize": { - "description": "`handSize` is a small positive number that configures the shuffle sharding of requests into queues. When enqueuing a request at this priority level the request's flow identifier (a string pair) is hashed and the hash value is used to shuffle the list of queues and deal a hand of the size specified here. The request is put into one of the shortest queues in that hand. `handSize` must be no larger than `queues`, and should be significantly smaller (so that a few heavy flows do not saturate most of the queues). See the user-facing documentation for more extensive guidance on setting this field. This field has a default value of 8.", - "format": "int32", - "type": "integer" + "error": { + "description": "error is to record the problem with the service port The format of the error shall comply with the following rules: - built-in error values shall be specified in this file and those shall use\n CamelCase names\n- cloud provider specific error values must have names that comply with the\n format foo.example.com/CamelCase.", + "type": "string" }, - "queueLengthLimit": { - "description": "`queueLengthLimit` is the maximum number of requests allowed to be waiting in a given queue of this priority level at a time; excess requests are rejected. This value must be positive. If not specified, it will be defaulted to 50.", + "port": { + "description": "port is the port number of the ingress port.", "format": "int32", "type": "integer" }, - "queues": { - "description": "`queues` is the number of queues for this priority level. The queues exist independently at each apiserver. The value must be positive. Setting it to 1 effectively precludes shufflesharding and thus makes the distinguisher method of associated flow schemas irrelevant. This field has a default value of 64.", - "format": "int32", - "type": "integer" + "protocol": { + "description": "protocol is the protocol of the ingress port. The supported values are: \"TCP\", \"UDP\", \"SCTP\"", + "type": "string" } }, + "required": [ + "port", + "protocol" + ], "type": "object" }, - "v1beta2.ResourcePolicyRule": { - "description": "ResourcePolicyRule is a predicate that matches some resource requests, testing the request's verb and the target resource. A ResourcePolicyRule matches a resource request if and only if: (a) at least one member of verbs matches the request, (b) at least one member of apiGroups matches the request, (c) at least one member of resources matches the request, and (d) either (d1) the request does not specify a namespace (i.e., `Namespace==\"\"`) and clusterScope is true or (d2) the request specifies a namespace and least one member of namespaces matches the request's namespace.", + "v1.IngressRule": { + "description": "IngressRule represents the rules mapping the paths under a specified host to the related backend services. Incoming requests are first evaluated for a host match, then routed to the backend associated with the matching IngressRuleValue.", "properties": { - "apiGroups": { - "description": "`apiGroups` is a list of matching API groups and may not be empty. \"*\" matches all API groups and, if present, must be the only entry. Required.", - "items": { - "type": "string" - }, - "type": "array", - "x-kubernetes-list-type": "set" - }, - "clusterScope": { - "description": "`clusterScope` indicates whether to match requests that do not specify a namespace (which happens either because the resource is not namespaced or the request targets all namespaces). If this field is omitted or false then the `namespaces` field must contain a non-empty list.", - "type": "boolean" - }, - "namespaces": { - "description": "`namespaces` is a list of target namespaces that restricts matches. A request that specifies a target namespace matches only if either (a) this list contains that target namespace or (b) this list contains \"*\". Note that \"*\" matches any specified namespace but does not match a request that _does not specify_ a namespace (see the `clusterScope` field for that). This list may be empty, but only if `clusterScope` is true.", - "items": { - "type": "string" - }, - "type": "array", - "x-kubernetes-list-type": "set" - }, - "resources": { - "description": "`resources` is a list of matching resources (i.e., lowercase and plural) with, if desired, subresource. For example, [ \"services\", \"nodes/status\" ]. This list may not be empty. \"*\" matches all resources and, if present, must be the only entry. Required.", - "items": { - "type": "string" - }, - "type": "array", - "x-kubernetes-list-type": "set" + "host": { + "description": "host is the fully qualified domain name of a network host, as defined by RFC 3986. Note the following deviations from the \"host\" part of the URI as defined in RFC 3986: 1. IPs are not allowed. Currently an IngressRuleValue can only apply to\n the IP in the Spec of the parent Ingress.\n2. The `:` delimiter is not respected because ports are not allowed.\n\t Currently the port of an Ingress is implicitly :80 for http and\n\t :443 for https.\nBoth these may change in the future. Incoming requests are matched against the host before the IngressRuleValue. If the host is unspecified, the Ingress routes all traffic based on the specified IngressRuleValue.\n\nhost can be \"precise\" which is a domain name without the terminating dot of a network host (e.g. \"foo.bar.com\") or \"wildcard\", which is a domain name prefixed with a single wildcard label (e.g. \"*.foo.com\"). The wildcard character '*' must appear by itself as the first DNS label and matches only a single label. You cannot have a wildcard label by itself (e.g. Host == \"*\"). Requests will be matched against the Host field in the following way: 1. If host is precise, the request matches this rule if the http host header is equal to Host. 2. If host is a wildcard, then the request matches this rule if the http host header is to equal to the suffix (removing the first label) of the wildcard rule.", + "type": "string" }, - "verbs": { - "description": "`verbs` is a list of matching verbs and may not be empty. \"*\" matches all verbs and, if present, must be the only entry. Required.", - "items": { - "type": "string" - }, - "type": "array", - "x-kubernetes-list-type": "set" + "http": { + "$ref": "#/definitions/v1.HTTPIngressRuleValue" } }, - "required": [ - "verbs", - "apiGroups", - "resources" - ], "type": "object" }, - "v1beta2.ServiceAccountSubject": { - "description": "ServiceAccountSubject holds detailed information for service-account-kind subject.", + "v1.IngressServiceBackend": { + "description": "IngressServiceBackend references a Kubernetes Service as a Backend.", "properties": { "name": { - "description": "`name` is the name of matching ServiceAccount objects, or \"*\" to match regardless of name. Required.", + "description": "name is the referenced service. The service must exist in the same namespace as the Ingress object.", "type": "string" }, - "namespace": { - "description": "`namespace` is the namespace of matching ServiceAccount objects. Required.", - "type": "string" + "port": { + "$ref": "#/definitions/v1.ServiceBackendPort", + "description": "port of the referenced service. A port name or port number is required for a IngressServiceBackend." } }, "required": [ - "namespace", "name" ], "type": "object" }, - "v1beta2.Subject": { - "description": "Subject matches the originator of a request, as identified by the request authentication system. There are three ways of matching an originator; by user, group, or service account.", + "v1.IngressSpec": { + "description": "IngressSpec describes the Ingress the user wishes to exist.", "properties": { - "group": { - "$ref": "#/definitions/v1beta2.GroupSubject", - "description": "`group` matches based on user group name." + "defaultBackend": { + "$ref": "#/definitions/v1.IngressBackend", + "description": "defaultBackend is the backend that should handle requests that don't match any rule. If Rules are not specified, DefaultBackend must be specified. If DefaultBackend is not set, the handling of requests that do not match any of the rules will be up to the Ingress controller." }, - "kind": { - "description": "`kind` indicates which one of the other fields is non-empty. Required", + "ingressClassName": { + "description": "ingressClassName is the name of an IngressClass cluster resource. Ingress controller implementations use this field to know whether they should be serving this Ingress resource, by a transitive connection (controller -> IngressClass -> Ingress resource). Although the `kubernetes.io/ingress.class` annotation (simple constant name) was never formally defined, it was widely supported by Ingress controllers to create a direct binding between Ingress controller and Ingress resources. Newly created Ingress resources should prefer using the field. However, even though the annotation is officially deprecated, for backwards compatibility reasons, ingress controllers should still honor that annotation if present.", "type": "string" }, - "serviceAccount": { - "$ref": "#/definitions/v1beta2.ServiceAccountSubject", - "description": "`serviceAccount` matches ServiceAccounts." + "rules": { + "description": "rules is a list of host rules used to configure the Ingress. If unspecified, or no rule matches, all traffic is sent to the default backend.", + "items": { + "$ref": "#/definitions/v1.IngressRule" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" }, - "user": { - "$ref": "#/definitions/v1beta2.UserSubject", - "description": "`user` matches based on username." + "tls": { + "description": "tls represents the TLS configuration. Currently the Ingress only supports a single TLS port, 443. If multiple members of this list specify different hosts, they will be multiplexed on the same port according to the hostname specified through the SNI TLS extension, if the ingress controller fulfilling the ingress supports SNI.", + "items": { + "$ref": "#/definitions/v1.IngressTLS" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" } }, - "required": [ - "kind" - ], - "type": "object", - "x-kubernetes-unions": [ - { - "discriminator": "kind", - "fields-to-discriminateBy": { - "group": "Group", - "serviceAccount": "ServiceAccount", - "user": "User" - } - } - ] - }, - "v1beta2.UserSubject": { - "description": "UserSubject holds detailed information for user-kind subject.", - "properties": { - "name": { - "description": "`name` is the username that matches, or \"*\" to match all usernames. Required.", - "type": "string" - } - }, - "required": [ - "name" - ], "type": "object" }, - "v1.HTTPIngressPath": { - "description": "HTTPIngressPath associates a path with a backend. Incoming urls matching the path are forwarded to the backend.", + "v1.IngressStatus": { + "description": "IngressStatus describe the current state of the Ingress.", "properties": { - "backend": { - "$ref": "#/definitions/v1.IngressBackend", - "description": "Backend defines the referenced service endpoint to which the traffic will be forwarded to." - }, - "path": { - "description": "Path is matched against the path of an incoming request. Currently it can contain characters disallowed from the conventional \"path\" part of a URL as defined by RFC 3986. Paths must begin with a '/' and must be present when using PathType with value \"Exact\" or \"Prefix\".", - "type": "string" - }, - "pathType": { - "description": "PathType determines the interpretation of the Path matching. PathType can be one of the following values: * Exact: Matches the URL path exactly. * Prefix: Matches based on a URL path prefix split by '/'. Matching is\n done on a path element by element basis. A path element refers is the\n list of labels in the path split by the '/' separator. A request is a\n match for path p if every p is an element-wise prefix of p of the\n request path. Note that if the last element of the path is a substring\n of the last element in request path, it is not a match (e.g. /foo/bar\n matches /foo/bar/baz, but does not match /foo/barbaz).\n* ImplementationSpecific: Interpretation of the Path matching is up to\n the IngressClass. Implementations can treat this as a separate PathType\n or treat it identically to Prefix or Exact path types.\nImplementations are required to support all path types.", - "type": "string" + "loadBalancer": { + "$ref": "#/definitions/v1.IngressLoadBalancerStatus", + "description": "loadBalancer contains the current status of the load-balancer." } }, - "required": [ - "pathType", - "backend" - ], "type": "object" }, - "v1.HTTPIngressRuleValue": { - "description": "HTTPIngressRuleValue is a list of http selectors pointing to backends. In the example: http:///? -> backend where where parts of the url correspond to RFC 3986, this resource will be used to match against everything after the last '/' and before the first '?' or '#'.", + "v1.IngressTLS": { + "description": "IngressTLS describes the transport layer security associated with an ingress.", "properties": { - "paths": { - "description": "A collection of paths that map requests to backends.", + "hosts": { + "description": "hosts is a list of hosts included in the TLS certificate. The values in this list must match the name/s used in the tlsSecret. Defaults to the wildcard host setting for the loadbalancer controller fulfilling this Ingress, if left unspecified.", "items": { - "$ref": "#/definitions/v1.HTTPIngressPath" + "type": "string" }, "type": "array", "x-kubernetes-list-type": "atomic" - } - }, - "required": [ - "paths" - ], - "type": "object" - }, - "v1.IPBlock": { - "description": "IPBlock describes a particular CIDR (Ex. \"192.168.1.1/24\",\"2001:db9::/64\") that is allowed to the pods matched by a NetworkPolicySpec's podSelector. The except entry describes CIDRs that should not be included within this rule.", - "properties": { - "cidr": { - "description": "CIDR is a string representing the IP Block Valid examples are \"192.168.1.1/24\" or \"2001:db9::/64\"", - "type": "string" }, - "except": { - "description": "Except is a slice of CIDRs that should not be included within an IP Block Valid examples are \"192.168.1.1/24\" or \"2001:db9::/64\" Except values will be rejected if they are outside the CIDR range", - "items": { - "type": "string" - }, - "type": "array" + "secretName": { + "description": "secretName is the name of the secret used to terminate TLS traffic on port 443. Field is left optional to allow TLS routing based on SNI hostname alone. If the SNI host in a listener conflicts with the \"Host\" header field used by an IngressRule, the SNI host is used for termination and value of the \"Host\" header is used for routing.", + "type": "string" } }, - "required": [ - "cidr" - ], "type": "object" }, - "v1.Ingress": { - "description": "Ingress is a collection of rules that allow inbound connections to reach the endpoints defined by a backend. An Ingress can be configured to give services externally-reachable urls, load balance traffic, terminate SSL, offer name based virtual hosting etc.", + "v1.NetworkPolicy": { + "description": "NetworkPolicy describes what network traffic is allowed for a set of Pods", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", @@ -11650,77 +14054,74 @@ "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" }, "spec": { - "$ref": "#/definitions/v1.IngressSpec", - "description": "Spec is the desired state of the Ingress. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" - }, - "status": { - "$ref": "#/definitions/v1.IngressStatus", - "description": "Status is the current state of the Ingress. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" + "$ref": "#/definitions/v1.NetworkPolicySpec", + "description": "spec represents the specification of the desired behavior for this NetworkPolicy." } }, "type": "object", "x-kubernetes-group-version-kind": [ { "group": "networking.k8s.io", - "kind": "Ingress", + "kind": "NetworkPolicy", "version": "v1" } ] }, - "v1.IngressBackend": { - "description": "IngressBackend describes all endpoints for a given service and port.", + "v1.NetworkPolicyEgressRule": { + "description": "NetworkPolicyEgressRule describes a particular set of traffic that is allowed out of pods matched by a NetworkPolicySpec's podSelector. The traffic must match both ports and to. This type is beta-level in 1.8", "properties": { - "resource": { - "$ref": "#/definitions/v1.TypedLocalObjectReference", - "description": "Resource is an ObjectRef to another Kubernetes resource in the namespace of the Ingress object. If resource is specified, a service.Name and service.Port must not be specified. This is a mutually exclusive setting with \"Service\"." + "ports": { + "description": "ports is a list of destination ports for outgoing traffic. Each item in this list is combined using a logical OR. If this field is empty or missing, this rule matches all ports (traffic not restricted by port). If this field is present and contains at least one item, then this rule allows traffic only if the traffic matches at least one port in the list.", + "items": { + "$ref": "#/definitions/v1.NetworkPolicyPort" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" }, - "service": { - "$ref": "#/definitions/v1.IngressServiceBackend", - "description": "Service references a Service as a Backend. This is a mutually exclusive setting with \"Resource\"." + "to": { + "description": "to is a list of destinations for outgoing traffic of pods selected for this rule. Items in this list are combined using a logical OR operation. If this field is empty or missing, this rule matches all destinations (traffic not restricted by destination). If this field is present and contains at least one item, this rule allows traffic only if the traffic matches at least one item in the to list.", + "items": { + "$ref": "#/definitions/v1.NetworkPolicyPeer" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object" }, - "v1.IngressClass": { - "description": "IngressClass represents the class of the Ingress, referenced by the Ingress Spec. The `ingressclass.kubernetes.io/is-default-class` annotation can be used to indicate that an IngressClass should be considered default. When a single IngressClass resource has this annotation set to true, new Ingress resources without a class specified will be assigned this default class.", + "v1.NetworkPolicyIngressRule": { + "description": "NetworkPolicyIngressRule describes a particular set of traffic that is allowed to the pods matched by a NetworkPolicySpec's podSelector. The traffic must match both ports and from.", "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "metadata": { - "$ref": "#/definitions/v1.ObjectMeta", - "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + "from": { + "description": "from is a list of sources which should be able to access the pods selected for this rule. Items in this list are combined using a logical OR operation. If this field is empty or missing, this rule matches all sources (traffic not restricted by source). If this field is present and contains at least one item, this rule allows traffic only if the traffic matches at least one item in the from list.", + "items": { + "$ref": "#/definitions/v1.NetworkPolicyPeer" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" }, - "spec": { - "$ref": "#/definitions/v1.IngressClassSpec", - "description": "Spec is the desired state of the IngressClass. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" + "ports": { + "description": "ports is a list of ports which should be made accessible on the pods selected for this rule. Each item in this list is combined using a logical OR. If this field is empty or missing, this rule matches all ports (traffic not restricted by port). If this field is present and contains at least one item, then this rule allows traffic only if the traffic matches at least one port in the list.", + "items": { + "$ref": "#/definitions/v1.NetworkPolicyPort" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" } }, - "type": "object", - "x-kubernetes-group-version-kind": [ - { - "group": "networking.k8s.io", - "kind": "IngressClass", - "version": "v1" - } - ] + "type": "object" }, - "v1.IngressClassList": { - "description": "IngressClassList is a collection of IngressClasses.", + "v1.NetworkPolicyList": { + "description": "NetworkPolicyList is a list of NetworkPolicy objects.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, "items": { - "description": "Items is the list of IngressClasses.", + "description": "items is a list of schema objects.", "items": { - "$ref": "#/definitions/v1.IngressClass" + "$ref": "#/definitions/v1.NetworkPolicy" }, "type": "array" }, @@ -11730,7 +14131,7 @@ }, "metadata": { "$ref": "#/definitions/v1.ListMeta", - "description": "Standard list metadata." + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" } }, "required": [ @@ -11740,143 +14141,199 @@ "x-kubernetes-group-version-kind": [ { "group": "networking.k8s.io", - "kind": "IngressClassList", + "kind": "NetworkPolicyList", "version": "v1" } ] }, - "v1.IngressClassParametersReference": { - "description": "IngressClassParametersReference identifies an API object. This can be used to specify a cluster or namespace-scoped resource.", + "v1.NetworkPolicyPeer": { + "description": "NetworkPolicyPeer describes a peer to allow traffic to/from. Only certain combinations of fields are allowed", "properties": { - "apiGroup": { - "description": "APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required.", + "ipBlock": { + "$ref": "#/definitions/v1.IPBlock", + "description": "ipBlock defines policy on a particular IPBlock. If this field is set then neither of the other fields can be." + }, + "namespaceSelector": { + "$ref": "#/definitions/v1.LabelSelector", + "description": "namespaceSelector selects namespaces using cluster-scoped labels. This field follows standard label selector semantics; if present but empty, it selects all namespaces.\n\nIf podSelector is also set, then the NetworkPolicyPeer as a whole selects the pods matching podSelector in the namespaces selected by namespaceSelector. Otherwise it selects all pods in the namespaces selected by namespaceSelector." + }, + "podSelector": { + "$ref": "#/definitions/v1.LabelSelector", + "description": "podSelector is a label selector which selects pods. This field follows standard label selector semantics; if present but empty, it selects all pods.\n\nIf namespaceSelector is also set, then the NetworkPolicyPeer as a whole selects the pods matching podSelector in the Namespaces selected by NamespaceSelector. Otherwise it selects the pods matching podSelector in the policy's own namespace." + } + }, + "type": "object" + }, + "v1.NetworkPolicyPort": { + "description": "NetworkPolicyPort describes a port to allow traffic on", + "properties": { + "endPort": { + "description": "endPort indicates that the range of ports from port to endPort if set, inclusive, should be allowed by the policy. This field cannot be defined if the port field is not defined or if the port field is defined as a named (string) port. The endPort must be equal or greater than port.", + "format": "int32", + "type": "integer" + }, + "port": { + "$ref": "#/definitions/intstr.IntOrString", + "description": "port represents the port on the given protocol. This can either be a numerical or named port on a pod. If this field is not provided, this matches all port names and numbers. If present, only traffic on the specified protocol AND port will be matched." + }, + "protocol": { + "description": "protocol represents the protocol (TCP, UDP, or SCTP) which traffic must match. If not specified, this field defaults to TCP.", "type": "string" + } + }, + "type": "object" + }, + "v1.NetworkPolicySpec": { + "description": "NetworkPolicySpec provides the specification of a NetworkPolicy", + "properties": { + "egress": { + "description": "egress is a list of egress rules to be applied to the selected pods. Outgoing traffic is allowed if there are no NetworkPolicies selecting the pod (and cluster policy otherwise allows the traffic), OR if the traffic matches at least one egress rule across all of the NetworkPolicy objects whose podSelector matches the pod. If this field is empty then this NetworkPolicy limits all outgoing traffic (and serves solely to ensure that the pods it selects are isolated by default). This field is beta-level in 1.8", + "items": { + "$ref": "#/definitions/v1.NetworkPolicyEgressRule" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" }, - "kind": { - "description": "Kind is the type of resource being referenced.", + "ingress": { + "description": "ingress is a list of ingress rules to be applied to the selected pods. Traffic is allowed to a pod if there are no NetworkPolicies selecting the pod (and cluster policy otherwise allows the traffic), OR if the traffic source is the pod's local node, OR if the traffic matches at least one ingress rule across all of the NetworkPolicy objects whose podSelector matches the pod. If this field is empty then this NetworkPolicy does not allow any traffic (and serves solely to ensure that the pods it selects are isolated by default)", + "items": { + "$ref": "#/definitions/v1.NetworkPolicyIngressRule" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "podSelector": { + "$ref": "#/definitions/v1.LabelSelector", + "description": "podSelector selects the pods to which this NetworkPolicy object applies. The array of rules is applied to any pods selected by this field. An empty selector matches all pods in the policy's namespace. Multiple network policies can select the same set of pods. In this case, the ingress rules for each are combined additively. This field is optional. If it is not specified, it defaults to an empty selector." + }, + "policyTypes": { + "description": "policyTypes is a list of rule types that the NetworkPolicy relates to. Valid options are [\"Ingress\"], [\"Egress\"], or [\"Ingress\", \"Egress\"]. If this field is not specified, it will default based on the existence of ingress or egress rules; policies that contain an egress section are assumed to affect egress, and all policies (whether or not they contain an ingress section) are assumed to affect ingress. If you want to write an egress-only policy, you must explicitly specify policyTypes [ \"Egress\" ]. Likewise, if you want to write a policy that specifies that no egress is allowed, you must specify a policyTypes value that include \"Egress\" (since such a policy would not include an egress section and would otherwise default to just [ \"Ingress\" ]). This field is beta-level in 1.8", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + } + }, + "type": "object" + }, + "v1.ParentReference": { + "description": "ParentReference describes a reference to a parent object.", + "properties": { + "group": { + "description": "Group is the group of the object being referenced.", "type": "string" }, "name": { - "description": "Name is the name of resource being referenced.", + "description": "Name is the name of the object being referenced.", "type": "string" }, "namespace": { - "description": "Namespace is the namespace of the resource being referenced. This field is required when scope is set to \"Namespace\" and must be unset when scope is set to \"Cluster\".", + "description": "Namespace is the namespace of the object being referenced.", "type": "string" }, - "scope": { - "description": "Scope represents if this refers to a cluster or namespace scoped resource. This may be set to \"Cluster\" (default) or \"Namespace\".", + "resource": { + "description": "Resource is the resource of the object being referenced.", "type": "string" } }, "required": [ - "kind", + "resource", "name" ], "type": "object" }, - "v1.IngressClassSpec": { - "description": "IngressClassSpec provides information about the class of an Ingress.", + "v1.ServiceBackendPort": { + "description": "ServiceBackendPort is the service port being referenced.", "properties": { - "controller": { - "description": "Controller refers to the name of the controller that should handle this class. This allows for different \"flavors\" that are controlled by the same controller. For example, you may have different Parameters for the same implementing controller. This should be specified as a domain-prefixed path no more than 250 characters in length, e.g. \"acme.io/ingress-controller\". This field is immutable.", + "name": { + "description": "name is the name of the port on the Service. This is a mutually exclusive setting with \"Number\".", "type": "string" }, - "parameters": { - "$ref": "#/definitions/v1.IngressClassParametersReference", - "description": "Parameters is a link to a custom resource containing additional configuration for the controller. This is optional if the controller does not require extra parameters." + "number": { + "description": "number is the numerical port number (e.g. 80) on the Service. This is a mutually exclusive setting with \"Name\".", + "format": "int32", + "type": "integer" } }, - "type": "object" + "type": "object", + "x-kubernetes-map-type": "atomic" }, - "v1.IngressList": { - "description": "IngressList is a collection of Ingress.", + "v1.ServiceCIDR": { + "description": "ServiceCIDR defines a range of IP addresses using CIDR format (e.g. 192.168.0.0/24 or 2001:db2::/64). This range is used to allocate ClusterIPs to Service objects.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, - "items": { - "description": "Items is the list of Ingress.", - "items": { - "$ref": "#/definitions/v1.Ingress" - }, - "type": "array" - }, "kind": { "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", "type": "string" }, "metadata": { - "$ref": "#/definitions/v1.ListMeta", + "$ref": "#/definitions/v1.ObjectMeta", "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + }, + "spec": { + "$ref": "#/definitions/v1.ServiceCIDRSpec", + "description": "spec is the desired state of the ServiceCIDR. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" + }, + "status": { + "$ref": "#/definitions/v1.ServiceCIDRStatus", + "description": "status represents the current state of the ServiceCIDR. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, - "required": [ - "items" - ], "type": "object", "x-kubernetes-group-version-kind": [ { "group": "networking.k8s.io", - "kind": "IngressList", + "kind": "ServiceCIDR", "version": "v1" } ] }, - "v1.IngressRule": { - "description": "IngressRule represents the rules mapping the paths under a specified host to the related backend services. Incoming requests are first evaluated for a host match, then routed to the backend associated with the matching IngressRuleValue.", + "v1.ServiceCIDRList": { + "description": "ServiceCIDRList contains a list of ServiceCIDR objects.", "properties": { - "host": { - "description": "Host is the fully qualified domain name of a network host, as defined by RFC 3986. Note the following deviations from the \"host\" part of the URI as defined in RFC 3986: 1. IPs are not allowed. Currently an IngressRuleValue can only apply to\n the IP in the Spec of the parent Ingress.\n2. The `:` delimiter is not respected because ports are not allowed.\n\t Currently the port of an Ingress is implicitly :80 for http and\n\t :443 for https.\nBoth these may change in the future. Incoming requests are matched against the host before the IngressRuleValue. If the host is unspecified, the Ingress routes all traffic based on the specified IngressRuleValue.\n\nHost can be \"precise\" which is a domain name without the terminating dot of a network host (e.g. \"foo.bar.com\") or \"wildcard\", which is a domain name prefixed with a single wildcard label (e.g. \"*.foo.com\"). The wildcard character '*' must appear by itself as the first DNS label and matches only a single label. You cannot have a wildcard label by itself (e.g. Host == \"*\"). Requests will be matched against the Host field in the following way: 1. If Host is precise, the request matches this rule if the http host header is equal to Host. 2. If Host is a wildcard, then the request matches this rule if the http host header is to equal to the suffix (removing the first label) of the wildcard rule.", + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, - "http": { - "$ref": "#/definitions/v1.HTTPIngressRuleValue" - } - }, - "type": "object" - }, - "v1.IngressServiceBackend": { - "description": "IngressServiceBackend references a Kubernetes Service as a Backend.", - "properties": { - "name": { - "description": "Name is the referenced service. The service must exist in the same namespace as the Ingress object.", + "items": { + "description": "items is the list of ServiceCIDRs.", + "items": { + "$ref": "#/definitions/v1.ServiceCIDR" + }, + "type": "array" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", "type": "string" }, - "port": { - "$ref": "#/definitions/v1.ServiceBackendPort", - "description": "Port of the referenced service. A port name or port number is required for a IngressServiceBackend." + "metadata": { + "$ref": "#/definitions/v1.ListMeta", + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" } }, "required": [ - "name" + "items" ], - "type": "object" + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "networking.k8s.io", + "kind": "ServiceCIDRList", + "version": "v1" + } + ] }, - "v1.IngressSpec": { - "description": "IngressSpec describes the Ingress the user wishes to exist.", + "v1.ServiceCIDRSpec": { + "description": "ServiceCIDRSpec define the CIDRs the user wants to use for allocating ClusterIPs for Services.", "properties": { - "defaultBackend": { - "$ref": "#/definitions/v1.IngressBackend", - "description": "DefaultBackend is the backend that should handle requests that don't match any rule. If Rules are not specified, DefaultBackend must be specified. If DefaultBackend is not set, the handling of requests that do not match any of the rules will be up to the Ingress controller." - }, - "ingressClassName": { - "description": "IngressClassName is the name of an IngressClass cluster resource. Ingress controller implementations use this field to know whether they should be serving this Ingress resource, by a transitive connection (controller -> IngressClass -> Ingress resource). Although the `kubernetes.io/ingress.class` annotation (simple constant name) was never formally defined, it was widely supported by Ingress controllers to create a direct binding between Ingress controller and Ingress resources. Newly created Ingress resources should prefer using the field. However, even though the annotation is officially deprecated, for backwards compatibility reasons, ingress controllers should still honor that annotation if present.", - "type": "string" - }, - "rules": { - "description": "A list of host rules used to configure the Ingress. If unspecified, or no rule matches, all traffic is sent to the default backend.", - "items": { - "$ref": "#/definitions/v1.IngressRule" - }, - "type": "array", - "x-kubernetes-list-type": "atomic" - }, - "tls": { - "description": "TLS configuration. Currently the Ingress only supports a single TLS port, 443. If multiple members of this list specify different hosts, they will be multiplexed on the same port according to the hostname specified through the SNI TLS extension, if the ingress controller fulfilling the ingress supports SNI.", + "cidrs": { + "description": "CIDRs defines the IP blocks in CIDR notation (e.g. \"192.168.0.0/24\" or \"2001:db8::/64\") from which to assign service cluster IPs. Max of two CIDRs is allowed, one of each IP family. This field is immutable.", "items": { - "$ref": "#/definitions/v1.IngressTLS" + "type": "string" }, "type": "array", "x-kubernetes-list-type": "atomic" @@ -11884,36 +14341,27 @@ }, "type": "object" }, - "v1.IngressStatus": { - "description": "IngressStatus describe the current state of the Ingress.", - "properties": { - "loadBalancer": { - "$ref": "#/definitions/v1.LoadBalancerStatus", - "description": "LoadBalancer contains the current status of the load-balancer." - } - }, - "type": "object" - }, - "v1.IngressTLS": { - "description": "IngressTLS describes the transport layer security associated with an Ingress.", + "v1.ServiceCIDRStatus": { + "description": "ServiceCIDRStatus describes the current state of the ServiceCIDR.", "properties": { - "hosts": { - "description": "Hosts are a list of hosts included in the TLS certificate. The values in this list must match the name/s used in the tlsSecret. Defaults to the wildcard host setting for the loadbalancer controller fulfilling this Ingress, if left unspecified.", + "conditions": { + "description": "conditions holds an array of metav1.Condition that describe the state of the ServiceCIDR. Current service state", "items": { - "type": "string" + "$ref": "#/definitions/v1.Condition" }, "type": "array", - "x-kubernetes-list-type": "atomic" - }, - "secretName": { - "description": "SecretName is the name of the secret used to terminate TLS traffic on port 443. Field is left optional to allow TLS routing based on SNI hostname alone. If the SNI host in a listener conflicts with the \"Host\" header field used by an IngressRule, the SNI host is used for termination and value of the Host header is used for routing.", - "type": "string" + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" } }, "type": "object" }, - "v1.NetworkPolicy": { - "description": "NetworkPolicy describes what network traffic is allowed for a set of Pods", + "v1beta1.IPAddress": { + "description": "IPAddress represents a single IP of a single IP Family. The object is designed to be used by APIs that operate on IP addresses. The object is used by the Service core API for allocation of IP addresses. An IP address can be represented in different formats, to guarantee the uniqueness of the IP, the name of the object is the IP address in canonical format, four decimal digits separated by dots suppressing leading zeros for IPv4 and the representation defined by RFC 5952 for IPv6. Valid: 192.168.1.5 or 2001:db8::1 or 2001:db8:aaaa:bbbb:cccc:dddd:eeee:1 Invalid: 10.01.2.3 or 2001:db8:0:0:0::1", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", @@ -11928,74 +14376,30 @@ "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" }, "spec": { - "$ref": "#/definitions/v1.NetworkPolicySpec", - "description": "Specification of the desired behavior for this NetworkPolicy." - }, - "status": { - "$ref": "#/definitions/v1.NetworkPolicyStatus", - "description": "Status is the current state of the NetworkPolicy. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" + "$ref": "#/definitions/v1beta1.IPAddressSpec", + "description": "spec is the desired state of the IPAddress. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, "type": "object", "x-kubernetes-group-version-kind": [ { "group": "networking.k8s.io", - "kind": "NetworkPolicy", - "version": "v1" + "kind": "IPAddress", + "version": "v1beta1" } ] }, - "v1.NetworkPolicyEgressRule": { - "description": "NetworkPolicyEgressRule describes a particular set of traffic that is allowed out of pods matched by a NetworkPolicySpec's podSelector. The traffic must match both ports and to. This type is beta-level in 1.8", - "properties": { - "ports": { - "description": "List of destination ports for outgoing traffic. Each item in this list is combined using a logical OR. If this field is empty or missing, this rule matches all ports (traffic not restricted by port). If this field is present and contains at least one item, then this rule allows traffic only if the traffic matches at least one port in the list.", - "items": { - "$ref": "#/definitions/v1.NetworkPolicyPort" - }, - "type": "array" - }, - "to": { - "description": "List of destinations for outgoing traffic of pods selected for this rule. Items in this list are combined using a logical OR operation. If this field is empty or missing, this rule matches all destinations (traffic not restricted by destination). If this field is present and contains at least one item, this rule allows traffic only if the traffic matches at least one item in the to list.", - "items": { - "$ref": "#/definitions/v1.NetworkPolicyPeer" - }, - "type": "array" - } - }, - "type": "object" - }, - "v1.NetworkPolicyIngressRule": { - "description": "NetworkPolicyIngressRule describes a particular set of traffic that is allowed to the pods matched by a NetworkPolicySpec's podSelector. The traffic must match both ports and from.", - "properties": { - "from": { - "description": "List of sources which should be able to access the pods selected for this rule. Items in this list are combined using a logical OR operation. If this field is empty or missing, this rule matches all sources (traffic not restricted by source). If this field is present and contains at least one item, this rule allows traffic only if the traffic matches at least one item in the from list.", - "items": { - "$ref": "#/definitions/v1.NetworkPolicyPeer" - }, - "type": "array" - }, - "ports": { - "description": "List of ports which should be made accessible on the pods selected for this rule. Each item in this list is combined using a logical OR. If this field is empty or missing, this rule matches all ports (traffic not restricted by port). If this field is present and contains at least one item, then this rule allows traffic only if the traffic matches at least one port in the list.", - "items": { - "$ref": "#/definitions/v1.NetworkPolicyPort" - }, - "type": "array" - } - }, - "type": "object" - }, - "v1.NetworkPolicyList": { - "description": "NetworkPolicyList is a list of NetworkPolicy objects.", + "v1beta1.IPAddressList": { + "description": "IPAddressList contains a list of IPAddress.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, "items": { - "description": "Items is a list of schema objects.", + "description": "items is the list of IPAddresses.", "items": { - "$ref": "#/definitions/v1.NetworkPolicy" + "$ref": "#/definitions/v1beta1.IPAddress" }, "type": "array" }, @@ -12005,7 +14409,7 @@ }, "metadata": { "$ref": "#/definitions/v1.ListMeta", - "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" } }, "required": [ @@ -12015,118 +14419,52 @@ "x-kubernetes-group-version-kind": [ { "group": "networking.k8s.io", - "kind": "NetworkPolicyList", - "version": "v1" + "kind": "IPAddressList", + "version": "v1beta1" } ] }, - "v1.NetworkPolicyPeer": { - "description": "NetworkPolicyPeer describes a peer to allow traffic to/from. Only certain combinations of fields are allowed", + "v1beta1.IPAddressSpec": { + "description": "IPAddressSpec describe the attributes in an IP Address.", "properties": { - "ipBlock": { - "$ref": "#/definitions/v1.IPBlock", - "description": "IPBlock defines policy on a particular IPBlock. If this field is set then neither of the other fields can be." - }, - "namespaceSelector": { - "$ref": "#/definitions/v1.LabelSelector", - "description": "Selects Namespaces using cluster-scoped labels. This field follows standard label selector semantics; if present but empty, it selects all namespaces.\n\nIf PodSelector is also set, then the NetworkPolicyPeer as a whole selects the Pods matching PodSelector in the Namespaces selected by NamespaceSelector. Otherwise it selects all Pods in the Namespaces selected by NamespaceSelector." - }, - "podSelector": { - "$ref": "#/definitions/v1.LabelSelector", - "description": "This is a label selector which selects Pods. This field follows standard label selector semantics; if present but empty, it selects all pods.\n\nIf NamespaceSelector is also set, then the NetworkPolicyPeer as a whole selects the Pods matching PodSelector in the Namespaces selected by NamespaceSelector. Otherwise it selects the Pods matching PodSelector in the policy's own Namespace." + "parentRef": { + "$ref": "#/definitions/v1beta1.ParentReference", + "description": "ParentRef references the resource that an IPAddress is attached to. An IPAddress must reference a parent object." } }, + "required": [ + "parentRef" + ], "type": "object" }, - "v1.NetworkPolicyPort": { - "description": "NetworkPolicyPort describes a port to allow traffic on", + "v1beta1.ParentReference": { + "description": "ParentReference describes a reference to a parent object.", "properties": { - "endPort": { - "description": "If set, indicates that the range of ports from port to endPort, inclusive, should be allowed by the policy. This field cannot be defined if the port field is not defined or if the port field is defined as a named (string) port. The endPort must be equal or greater than port.", - "format": "int32", - "type": "integer" - }, - "port": { - "$ref": "#/definitions/intstr.IntOrString", - "description": "The port on the given protocol. This can either be a numerical or named port on a pod. If this field is not provided, this matches all port names and numbers. If present, only traffic on the specified protocol AND port will be matched." - }, - "protocol": { - "description": "The protocol (TCP, UDP, or SCTP) which traffic must match. If not specified, this field defaults to TCP.", + "group": { + "description": "Group is the group of the object being referenced.", "type": "string" - } - }, - "type": "object" - }, - "v1.NetworkPolicySpec": { - "description": "NetworkPolicySpec provides the specification of a NetworkPolicy", - "properties": { - "egress": { - "description": "List of egress rules to be applied to the selected pods. Outgoing traffic is allowed if there are no NetworkPolicies selecting the pod (and cluster policy otherwise allows the traffic), OR if the traffic matches at least one egress rule across all of the NetworkPolicy objects whose podSelector matches the pod. If this field is empty then this NetworkPolicy limits all outgoing traffic (and serves solely to ensure that the pods it selects are isolated by default). This field is beta-level in 1.8", - "items": { - "$ref": "#/definitions/v1.NetworkPolicyEgressRule" - }, - "type": "array" }, - "ingress": { - "description": "List of ingress rules to be applied to the selected pods. Traffic is allowed to a pod if there are no NetworkPolicies selecting the pod (and cluster policy otherwise allows the traffic), OR if the traffic source is the pod's local node, OR if the traffic matches at least one ingress rule across all of the NetworkPolicy objects whose podSelector matches the pod. If this field is empty then this NetworkPolicy does not allow any traffic (and serves solely to ensure that the pods it selects are isolated by default)", - "items": { - "$ref": "#/definitions/v1.NetworkPolicyIngressRule" - }, - "type": "array" + "name": { + "description": "Name is the name of the object being referenced.", + "type": "string" }, - "podSelector": { - "$ref": "#/definitions/v1.LabelSelector", - "description": "Selects the pods to which this NetworkPolicy object applies. The array of ingress rules is applied to any pods selected by this field. Multiple network policies can select the same set of pods. In this case, the ingress rules for each are combined additively. This field is NOT optional and follows standard label selector semantics. An empty podSelector matches all pods in this namespace." + "namespace": { + "description": "Namespace is the namespace of the object being referenced.", + "type": "string" }, - "policyTypes": { - "description": "List of rule types that the NetworkPolicy relates to. Valid options are [\"Ingress\"], [\"Egress\"], or [\"Ingress\", \"Egress\"]. If this field is not specified, it will default based on the existence of Ingress or Egress rules; policies that contain an Egress section are assumed to affect Egress, and all policies (whether or not they contain an Ingress section) are assumed to affect Ingress. If you want to write an egress-only policy, you must explicitly specify policyTypes [ \"Egress\" ]. Likewise, if you want to write a policy that specifies that no egress is allowed, you must specify a policyTypes value that include \"Egress\" (since such a policy would not include an Egress section and would otherwise default to just [ \"Ingress\" ]). This field is beta-level in 1.8", - "items": { - "type": "string" - }, - "type": "array" + "resource": { + "description": "Resource is the resource of the object being referenced.", + "type": "string" } }, "required": [ - "podSelector" + "resource", + "name" ], "type": "object" }, - "v1.NetworkPolicyStatus": { - "description": "NetworkPolicyStatus describe the current state of the NetworkPolicy.", - "properties": { - "conditions": { - "description": "Conditions holds an array of metav1.Condition that describe the state of the NetworkPolicy. Current service state", - "items": { - "$ref": "#/definitions/v1.Condition" - }, - "type": "array", - "x-kubernetes-list-map-keys": [ - "type" - ], - "x-kubernetes-list-type": "map", - "x-kubernetes-patch-merge-key": "type", - "x-kubernetes-patch-strategy": "merge" - } - }, - "type": "object" - }, - "v1.ServiceBackendPort": { - "description": "ServiceBackendPort is the service port being referenced.", - "properties": { - "name": { - "description": "Name is the name of the port on the Service. This is a mutually exclusive setting with \"Number\".", - "type": "string" - }, - "number": { - "description": "Number is the numerical port number (e.g. 80) on the Service. This is a mutually exclusive setting with \"Name\".", - "format": "int32", - "type": "integer" - } - }, - "type": "object" - }, - "v1alpha1.ClusterCIDR": { - "description": "ClusterCIDR represents a single configuration for per-Node Pod CIDR allocations when the MultiCIDRRangeAllocator is enabled (see the config for kube-controller-manager). A cluster may have any number of ClusterCIDR resources, all of which will be considered when allocating a CIDR for a Node. A ClusterCIDR is eligible to be used for a given Node when the node selector matches the node in question and has free CIDRs to allocate. In case of multiple matching ClusterCIDR resources, the allocator will attempt to break ties using internal heuristics, but any ClusterCIDR whose node selector matches the Node may be used.", + "v1beta1.ServiceCIDR": { + "description": "ServiceCIDR defines a range of IP addresses using CIDR format (e.g. 192.168.0.0/24 or 2001:db2::/64). This range is used to allocate ClusterIPs to Service objects.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", @@ -12141,30 +14479,34 @@ "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" }, "spec": { - "$ref": "#/definitions/v1alpha1.ClusterCIDRSpec", - "description": "Spec is the desired state of the ClusterCIDR. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" + "$ref": "#/definitions/v1beta1.ServiceCIDRSpec", + "description": "spec is the desired state of the ServiceCIDR. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" + }, + "status": { + "$ref": "#/definitions/v1beta1.ServiceCIDRStatus", + "description": "status represents the current state of the ServiceCIDR. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, "type": "object", "x-kubernetes-group-version-kind": [ { "group": "networking.k8s.io", - "kind": "ClusterCIDR", - "version": "v1alpha1" + "kind": "ServiceCIDR", + "version": "v1beta1" } ] }, - "v1alpha1.ClusterCIDRList": { - "description": "ClusterCIDRList contains a list of ClusterCIDR.", + "v1beta1.ServiceCIDRList": { + "description": "ServiceCIDRList contains a list of ServiceCIDR objects.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, "items": { - "description": "Items is the list of ClusterCIDRs.", + "description": "items is the list of ServiceCIDRs.", "items": { - "$ref": "#/definitions/v1alpha1.ClusterCIDR" + "$ref": "#/definitions/v1beta1.ServiceCIDR" }, "type": "array" }, @@ -12184,35 +14526,42 @@ "x-kubernetes-group-version-kind": [ { "group": "networking.k8s.io", - "kind": "ClusterCIDRList", - "version": "v1alpha1" + "kind": "ServiceCIDRList", + "version": "v1beta1" } ] }, - "v1alpha1.ClusterCIDRSpec": { - "description": "ClusterCIDRSpec defines the desired state of ClusterCIDR.", + "v1beta1.ServiceCIDRSpec": { + "description": "ServiceCIDRSpec define the CIDRs the user wants to use for allocating ClusterIPs for Services.", "properties": { - "ipv4": { - "description": "IPv4 defines an IPv4 IP block in CIDR notation(e.g. \"10.0.0.0/8\"). At least one of IPv4 and IPv6 must be specified. This field is immutable.", - "type": "string" - }, - "ipv6": { - "description": "IPv6 defines an IPv6 IP block in CIDR notation(e.g. \"fd12:3456:789a:1::/64\"). At least one of IPv4 and IPv6 must be specified. This field is immutable.", - "type": "string" - }, - "nodeSelector": { - "$ref": "#/definitions/v1.NodeSelector", - "description": "NodeSelector defines which nodes the config is applicable to. An empty or nil NodeSelector selects all nodes. This field is immutable." - }, - "perNodeHostBits": { - "description": "PerNodeHostBits defines the number of host bits to be configured per node. A subnet mask determines how much of the address is used for network bits and host bits. For example an IPv4 address of 192.168.0.0/24, splits the address into 24 bits for the network portion and 8 bits for the host portion. To allocate 256 IPs, set this field to 8 (a /24 mask for IPv4 or a /120 for IPv6). Minimum value is 4 (16 IPs). This field is immutable.", - "format": "int32", - "type": "integer" + "cidrs": { + "description": "CIDRs defines the IP blocks in CIDR notation (e.g. \"192.168.0.0/24\" or \"2001:db8::/64\") from which to assign service cluster IPs. Max of two CIDRs is allowed, one of each IP family. This field is immutable.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + } + }, + "type": "object" + }, + "v1beta1.ServiceCIDRStatus": { + "description": "ServiceCIDRStatus describes the current state of the ServiceCIDR.", + "properties": { + "conditions": { + "description": "conditions holds an array of metav1.Condition that describe the state of the ServiceCIDR. Current service state", + "items": { + "$ref": "#/definitions/v1.Condition" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" } }, - "required": [ - "perNodeHostBits" - ], "type": "object" }, "v1.Overhead": { @@ -12222,7 +14571,7 @@ "additionalProperties": { "$ref": "#/definitions/resource.Quantity" }, - "description": "PodFixed represents the fixed resource overhead associated with running a pod.", + "description": "podFixed represents the fixed resource overhead associated with running a pod.", "type": "object" } }, @@ -12236,7 +14585,7 @@ "type": "string" }, "handler": { - "description": "Handler specifies the underlying runtime and configuration that the CRI implementation will use to handle pods of this class. The possible values are specific to the node & CRI configuration. It is assumed that all handlers are available on every node, and handlers of the same name are equivalent on every node. For example, a handler called \"runc\" might specify that the runc OCI runtime (using native Linux containers) will be used to run the containers in a pod. The Handler must be lowercase, conform to the DNS Label (RFC 1123) requirements, and is immutable.", + "description": "handler specifies the underlying runtime and configuration that the CRI implementation will use to handle pods of this class. The possible values are specific to the node & CRI configuration. It is assumed that all handlers are available on every node, and handlers of the same name are equivalent on every node. For example, a handler called \"runc\" might specify that the runc OCI runtime (using native Linux containers) will be used to run the containers in a pod. The Handler must be lowercase, conform to the DNS Label (RFC 1123) requirements, and is immutable.", "type": "string" }, "kind": { @@ -12249,11 +14598,11 @@ }, "overhead": { "$ref": "#/definitions/v1.Overhead", - "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see\n https://kubernetes.io/docs/concepts/scheduling-eviction/pod-overhead/" + "description": "overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see\n https://kubernetes.io/docs/concepts/scheduling-eviction/pod-overhead/" }, "scheduling": { "$ref": "#/definitions/v1.Scheduling", - "description": "Scheduling holds the scheduling constraints to ensure that pods running with this RuntimeClass are scheduled to nodes that support it. If scheduling is nil, this RuntimeClass is assumed to be supported by all nodes." + "description": "scheduling holds the scheduling constraints to ensure that pods running with this RuntimeClass are scheduled to nodes that support it. If scheduling is nil, this RuntimeClass is assumed to be supported by all nodes." } }, "required": [ @@ -12276,7 +14625,7 @@ "type": "string" }, "items": { - "description": "Items is a list of schema objects.", + "description": "items is a list of schema objects.", "items": { "$ref": "#/definitions/v1.RuntimeClass" }, @@ -12437,6 +14786,10 @@ "$ref": "#/definitions/v1.LabelSelector", "description": "Label query over pods whose evictions are managed by the disruption budget. A null selector will match no pods, while an empty ({}) selector will select all pods within the namespace.", "x-kubernetes-patch-strategy": "replace" + }, + "unhealthyPodEvictionPolicy": { + "description": "UnhealthyPodEvictionPolicy defines the criteria for when unhealthy pods should be considered for eviction. Current implementation considers healthy pods, as pods that have status.conditions item with type=\"Ready\",status=\"True\".\n\nValid policies are IfHealthyBudget and AlwaysAllow. If no policy is specified, the default behavior will be used, which corresponds to the IfHealthyBudget policy.\n\nIfHealthyBudget policy means that running pods (status.phase=\"Running\"), but not yet healthy can be evicted only if the guarded application is not disrupted (status.currentHealthy is at least equal to status.desiredHealthy). Healthy pods will be subject to the PDB for eviction.\n\nAlwaysAllow policy means that all running pods (status.phase=\"Running\"), but not yet healthy are considered disrupted and can be evicted regardless of whether the criteria in a PDB is met. This means perspective running pods of a disrupted application might not get a chance to become healthy. Healthy pods will be subject to the PDB for eviction.\n\nAdditional policies may be added in the future. Clients making eviction decisions should disallow eviction of unhealthy pods if they encounter an unrecognized policy in this field.", + "type": "string" } }, "type": "object" @@ -12508,7 +14861,8 @@ "items": { "$ref": "#/definitions/v1.LabelSelector" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object" @@ -12537,7 +14891,8 @@ "items": { "$ref": "#/definitions/v1.PolicyRule" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object", @@ -12566,14 +14921,15 @@ }, "roleRef": { "$ref": "#/definitions/v1.RoleRef", - "description": "RoleRef can only reference a ClusterRole in the global namespace. If the RoleRef cannot be resolved, the Authorizer must return an error." + "description": "RoleRef can only reference a ClusterRole in the global namespace. If the RoleRef cannot be resolved, the Authorizer must return an error. This field is immutable." }, "subjects": { "description": "Subjects holds references to the objects the role applies to.", "items": { - "$ref": "#/definitions/v1.Subject" + "$ref": "#/definitions/rbac.v1.Subject" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "required": [ @@ -12666,35 +15022,40 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "nonResourceURLs": { "description": "NonResourceURLs is a set of partial urls that a user should have access to. *s are allowed, but only as the full, final step in the path Since non-resource URLs are not namespaced, this field is only applicable for ClusterRoles referenced from a ClusterRoleBinding. Rules can either apply to API resources (such as \"pods\" or \"secrets\") or non-resource URL paths (such as \"/api\"), but not both.", "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "resourceNames": { "description": "ResourceNames is an optional white list of names that the rule applies to. An empty set means that everything is allowed.", "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "resources": { "description": "Resources is a list of resources this rule applies to. '*' represents all resources.", "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, "verbs": { "description": "Verbs is a list of Verbs that apply to ALL the ResourceKinds contained in this rule. '*' represents all verbs.", "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "required": [ @@ -12722,7 +15083,8 @@ "items": { "$ref": "#/definitions/v1.PolicyRule" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "type": "object", @@ -12751,14 +15113,15 @@ }, "roleRef": { "$ref": "#/definitions/v1.RoleRef", - "description": "RoleRef can reference a Role in the current namespace or a ClusterRole in the global namespace. If the RoleRef cannot be resolved, the Authorizer must return an error." + "description": "RoleRef can reference a Role in the current namespace or a ClusterRole in the global namespace. If the RoleRef cannot be resolved, the Authorizer must return an error. This field is immutable." }, "subjects": { "description": "Subjects holds references to the objects the role applies to.", "items": { - "$ref": "#/definitions/v1.Subject" + "$ref": "#/definitions/rbac.v1.Subject" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "required": [ @@ -12867,7 +15230,7 @@ "type": "object", "x-kubernetes-map-type": "atomic" }, - "v1.Subject": { + "rbac.v1.Subject": { "description": "Subject contains a reference to the object or user identities a role binding applies to. This can either hold a direct API object reference, or a value for non-objects such as user and group names.", "properties": { "apiGroup": { @@ -12894,201 +15257,390 @@ "type": "object", "x-kubernetes-map-type": "atomic" }, - "v1.PriorityClass": { - "description": "PriorityClass defines mapping from a priority class name to the priority integer value. The value can be any valid integer.", + "v1.AllocatedDeviceStatus": { + "description": "AllocatedDeviceStatus contains the status of an allocated device, if the driver chooses to report it. This may include driver-specific information.\n\nThe combination of Driver, Pool, Device, and ShareID must match the corresponding key in Status.Allocation.Devices.", "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" + "conditions": { + "description": "Conditions contains the latest observation of the device's state. If the device has been configured according to the class and claim config references, the `Ready` condition should be True.\n\nMust not contain more than 8 entries.", + "items": { + "$ref": "#/definitions/v1.Condition" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map" }, - "description": { - "description": "description is an arbitrary string that usually provides guidelines on when this priority class should be used.", - "type": "string" + "data": { + "description": "Data contains arbitrary driver-specific data.\n\nThe length of the raw data must be smaller or equal to 10 Ki.", + "type": "object" }, - "globalDefault": { - "description": "globalDefault specifies whether this PriorityClass should be considered as the default priority for pods that do not have any priority class. Only one PriorityClass can be marked as `globalDefault`. However, if more than one PriorityClasses exists with their `globalDefault` field set to true, the smallest value of such global default PriorityClasses will be used as the default priority.", - "type": "boolean" + "device": { + "description": "Device references one device instance via its name in the driver's resource pool. It must be a DNS label.", + "type": "string" }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "driver": { + "description": "Driver specifies the name of the DRA driver whose kubelet plugin should be invoked to process the allocation once the claim is needed on a node.\n\nMust be a DNS subdomain and should end with a DNS domain owned by the vendor of the driver.", "type": "string" }, - "metadata": { - "$ref": "#/definitions/v1.ObjectMeta", - "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + "networkData": { + "$ref": "#/definitions/v1.NetworkDeviceData", + "description": "NetworkData contains network-related information specific to the device." }, - "preemptionPolicy": { - "description": "PreemptionPolicy is the Policy for preempting pods with lower priority. One of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset.", + "pool": { + "description": "This name together with the driver name and the device name field identify which device was allocated (`//`).\n\nMust not be longer than 253 characters and may contain one or more DNS sub-domains separated by slashes.", "type": "string" }, - "value": { - "description": "The value of this priority class. This is the actual priority that pods receive when they have the name of this class in their pod spec.", - "format": "int32", - "type": "integer" + "shareID": { + "description": "ShareID uniquely identifies an individual allocation share of the device.", + "type": "string" } }, "required": [ - "value" + "driver", + "pool", + "device" ], - "type": "object", - "x-kubernetes-group-version-kind": [ - { - "group": "scheduling.k8s.io", - "kind": "PriorityClass", - "version": "v1" + "type": "object" + }, + "v1.AllocationResult": { + "description": "AllocationResult contains attributes of an allocated resource.", + "properties": { + "allocationTimestamp": { + "description": "AllocationTimestamp stores the time when the resources were allocated. This field is not guaranteed to be set, in which case that time is unknown.\n\nThis is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus feature gate.", + "format": "date-time", + "type": "string" + }, + "devices": { + "$ref": "#/definitions/v1.DeviceAllocationResult", + "description": "Devices is the result of allocating devices." + }, + "nodeSelector": { + "$ref": "#/definitions/v1.NodeSelector", + "description": "NodeSelector defines where the allocated resources are available. If unset, they are available everywhere." } - ] + }, + "type": "object" }, - "v1.PriorityClassList": { - "description": "PriorityClassList is a collection of priority classes.", + "v1.CELDeviceSelector": { + "description": "CELDeviceSelector contains a CEL expression for selecting a device.", "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "expression": { + "description": "Expression is a CEL expression which evaluates a single device. It must evaluate to true when the device under consideration satisfies the desired criteria, and false when it does not. Any other result is an error and causes allocation of devices to abort.\n\nThe expression's input is an object named \"device\", which carries the following properties:\n - driver (string): the name of the driver which defines this device.\n - attributes (map[string]object): the device's attributes, grouped by prefix\n (e.g. device.attributes[\"dra.example.com\"] evaluates to an object with all\n of the attributes which were prefixed by \"dra.example.com\".\n - capacity (map[string]object): the device's capacities, grouped by prefix.\n - allowMultipleAllocations (bool): the allowMultipleAllocations property of the device\n (v1.34+ with the DRAConsumableCapacity feature enabled).\n\nExample: Consider a device with driver=\"dra.example.com\", which exposes two attributes named \"model\" and \"ext.example.com/family\" and which exposes one capacity named \"modules\". This input to this expression would have the following fields:\n\n device.driver\n device.attributes[\"dra.example.com\"].model\n device.attributes[\"ext.example.com\"].family\n device.capacity[\"dra.example.com\"].modules\n\nThe device.driver field can be used to check for a specific driver, either as a high-level precondition (i.e. you only want to consider devices from this driver) or as part of a multi-clause expression that is meant to consider devices from different drivers.\n\nThe value type of each attribute is defined by the device definition, and users who write these expressions must consult the documentation for their specific drivers. The value type of each capacity is Quantity.\n\nIf an unknown prefix is used as a lookup in either device.attributes or device.capacity, an empty map will be returned. Any reference to an unknown field will cause an evaluation error and allocation to abort.\n\nA robust expression should check for the existence of attributes before referencing them.\n\nFor ease of use, the cel.bind() function is enabled, and can be used to simplify expressions that access multiple attributes with the same domain. For example:\n\n cel.bind(dra, device.attributes[\"dra.example.com\"], dra.someBool && dra.anotherBool)\n\nThe length of the expression must be smaller or equal to 10 Ki. The cost of evaluating it is also limited based on the estimated number of logical steps.", "type": "string" + } + }, + "required": [ + "expression" + ], + "type": "object" + }, + "v1.CapacityRequestPolicy": { + "description": "CapacityRequestPolicy defines how requests consume device capacity.\n\nMust not set more than one ValidRequestValues.", + "properties": { + "default": { + "$ref": "#/definitions/resource.Quantity", + "description": "Default specifies how much of this capacity is consumed by a request that does not contain an entry for it in DeviceRequest's Capacity." }, - "items": { - "description": "items is the list of PriorityClasses", + "validRange": { + "$ref": "#/definitions/v1.CapacityRequestPolicyRange", + "description": "ValidRange defines an acceptable quantity value range in consuming requests.\n\nIf this field is set, Default must be defined and it must fall within the defined ValidRange.\n\nIf the requested amount does not fall within the defined range, the request violates the policy, and this device cannot be allocated.\n\nIf the request doesn't contain this capacity entry, Default value is used." + }, + "validValues": { + "description": "ValidValues defines a set of acceptable quantity values in consuming requests.\n\nMust not contain more than 10 entries. Must be sorted in ascending order.\n\nIf this field is set, Default must be defined and it must be included in ValidValues list.\n\nIf the requested amount does not match any valid value but smaller than some valid values, the scheduler calculates the smallest valid value that is greater than or equal to the request. That is: min(ceil(requestedValue) \u2208 validValues), where requestedValue \u2264 max(validValues).\n\nIf the requested amount exceeds all valid values, the request violates the policy, and this device cannot be allocated.", "items": { - "$ref": "#/definitions/v1.PriorityClass" + "$ref": "#/definitions/resource.Quantity" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" + } + }, + "type": "object" + }, + "v1.CapacityRequestPolicyRange": { + "description": "CapacityRequestPolicyRange defines a valid range for consumable capacity values.\n\n - If the requested amount is less than Min, it is rounded up to the Min value.\n - If Step is set and the requested amount is between Min and Max but not aligned with Step,\n it will be rounded up to the next value equal to Min + (n * Step).\n - If Step is not set, the requested amount is used as-is if it falls within the range Min to Max (if set).\n - If the requested or rounded amount exceeds Max (if set), the request does not satisfy the policy,\n and the device cannot be allocated.", + "properties": { + "max": { + "$ref": "#/definitions/resource.Quantity", + "description": "Max defines the upper limit for capacity that can be requested.\n\nMax must be less than or equal to the capacity value. Min and requestPolicy.default must be less than or equal to the maximum." }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" + "min": { + "$ref": "#/definitions/resource.Quantity", + "description": "Min specifies the minimum capacity allowed for a consumption request.\n\nMin must be greater than or equal to zero, and less than or equal to the capacity value. requestPolicy.default must be more than or equal to the minimum." }, - "metadata": { - "$ref": "#/definitions/v1.ListMeta", - "description": "Standard list metadata More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + "step": { + "$ref": "#/definitions/resource.Quantity", + "description": "Step defines the step size between valid capacity amounts within the range.\n\nMax (if set) and requestPolicy.default must be a multiple of Step. Min + Step must be less than or equal to the capacity value." } }, "required": [ - "items" + "min" ], - "type": "object", - "x-kubernetes-group-version-kind": [ - { - "group": "scheduling.k8s.io", - "kind": "PriorityClassList", - "version": "v1" + "type": "object" + }, + "v1.CapacityRequirements": { + "description": "CapacityRequirements defines the capacity requirements for a specific device request.", + "properties": { + "requests": { + "additionalProperties": { + "$ref": "#/definitions/resource.Quantity" + }, + "description": "Requests represent individual device resource requests for distinct resources, all of which must be provided by the device.\n\nThis value is used as an additional filtering condition against the available capacity on the device. This is semantically equivalent to a CEL selector with `device.capacity[]..compareTo(quantity()) >= 0`. For example, device.capacity['test-driver.cdi.k8s.io'].counters.compareTo(quantity('2')) >= 0.\n\nWhen a requestPolicy is defined, the requested amount is adjusted upward to the nearest valid value based on the policy. If the requested amount cannot be adjusted to a valid value\u2014because it exceeds what the requestPolicy allows\u2014 the device is considered ineligible for allocation.\n\nFor any capacity that is not explicitly requested: - If no requestPolicy is set, the default consumed capacity is equal to the full device capacity\n (i.e., the whole device is claimed).\n- If a requestPolicy is set, the default consumed capacity is determined according to that policy.\n\nIf the device allows multiple allocation, the aggregated amount across all requests must not exceed the capacity value. The consumed capacity, which may be adjusted based on the requestPolicy if defined, is recorded in the resource claim\u2019s status.devices[*].consumedCapacity field.", + "type": "object" } - ] + }, + "type": "object" }, - "v1.CSIDriver": { - "description": "CSIDriver captures information about a Container Storage Interface (CSI) volume driver deployed on the cluster. Kubernetes attach detach controller uses this object to determine whether attach is required. Kubelet uses this object to determine whether pod information needs to be passed on mount. CSIDriver objects are non-namespaced.", + "v1.Counter": { + "description": "Counter describes a quantity associated with a device.", "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "value": { + "$ref": "#/definitions/resource.Quantity", + "description": "Value defines how much of a certain device counter is available." + } + }, + "required": [ + "value" + ], + "type": "object" + }, + "v1.CounterSet": { + "description": "CounterSet defines a named set of counters that are available to be used by devices defined in the ResourceSlice.\n\nThe counters are not allocatable by themselves, but can be referenced by devices. When a device is allocated, the portion of counters it uses will no longer be available for use by other devices.", + "properties": { + "counters": { + "additionalProperties": { + "$ref": "#/definitions/v1.Counter" + }, + "description": "Counters defines the set of counters for this CounterSet The name of each counter must be unique in that set and must be a DNS label.\n\nThe maximum number of counters in all sets is 32.", + "type": "object" + }, + "name": { + "description": "Name defines the name of the counter set. It must be a DNS label.", "type": "string" + } + }, + "required": [ + "name", + "counters" + ], + "type": "object" + }, + "v1.Device": { + "description": "Device represents one individual hardware instance that can be selected based on its attributes. Besides the name, exactly one field must be set.", + "properties": { + "allNodes": { + "description": "AllNodes indicates that all nodes have access to the device.\n\nMust only be set if Spec.PerDeviceNodeSelection is set to true. At most one of NodeName, NodeSelector and AllNodes can be set.", + "type": "boolean" }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "allowMultipleAllocations": { + "description": "AllowMultipleAllocations marks whether the device is allowed to be allocated to multiple DeviceRequests.\n\nIf AllowMultipleAllocations is set to true, the device can be allocated more than once, and all of its capacity is consumable, regardless of whether the requestPolicy is defined or not.", + "type": "boolean" + }, + "attributes": { + "additionalProperties": { + "$ref": "#/definitions/v1.DeviceAttribute" + }, + "description": "Attributes defines the set of attributes for this device. The name of each attribute must be unique in that set.\n\nThe maximum number of attributes and capacities combined is 32.", + "type": "object" + }, + "bindingConditions": { + "description": "BindingConditions defines the conditions for proceeding with binding. All of these conditions must be set in the per-device status conditions with a value of True to proceed with binding the pod to the node while scheduling the pod.\n\nThe maximum number of binding conditions is 4.\n\nThe conditions must be a valid condition type string.\n\nThis is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus feature gates.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "bindingFailureConditions": { + "description": "BindingFailureConditions defines the conditions for binding failure. They may be set in the per-device status conditions. If any is set to \"True\", a binding failure occurred.\n\nThe maximum number of binding failure conditions is 4.\n\nThe conditions must be a valid condition type string.\n\nThis is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus feature gates.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "bindsToNode": { + "description": "BindsToNode indicates if the usage of an allocation involving this device has to be limited to exactly the node that was chosen when allocating the claim. If set to true, the scheduler will set the ResourceClaim.Status.Allocation.NodeSelector to match the node where the allocation was made.\n\nThis is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus feature gates.", + "type": "boolean" + }, + "capacity": { + "additionalProperties": { + "$ref": "#/definitions/v1.DeviceCapacity" + }, + "description": "Capacity defines the set of capacities for this device. The name of each capacity must be unique in that set.\n\nThe maximum number of attributes and capacities combined is 32.", + "type": "object" + }, + "consumesCounters": { + "description": "ConsumesCounters defines a list of references to sharedCounters and the set of counters that the device will consume from those counter sets.\n\nThere can only be a single entry per counterSet.\n\nThe total number of device counter consumption entries must be <= 32. In addition, the total number in the entire ResourceSlice must be <= 1024 (for example, 64 devices with 16 counters each).", + "items": { + "$ref": "#/definitions/v1.DeviceCounterConsumption" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "name": { + "description": "Name is unique identifier among all devices managed by the driver in the pool. It must be a DNS label.", "type": "string" }, - "metadata": { - "$ref": "#/definitions/v1.ObjectMeta", - "description": "Standard object metadata. metadata.Name indicates the name of the CSI driver that this object refers to; it MUST be the same name returned by the CSI GetPluginName() call for that driver. The driver name must be 63 characters or less, beginning and ending with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), dots (.), and alphanumerics between. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + "nodeName": { + "description": "NodeName identifies the node where the device is available.\n\nMust only be set if Spec.PerDeviceNodeSelection is set to true. At most one of NodeName, NodeSelector and AllNodes can be set.", + "type": "string" }, - "spec": { - "$ref": "#/definitions/v1.CSIDriverSpec", - "description": "Specification of the CSI Driver." + "nodeSelector": { + "$ref": "#/definitions/v1.NodeSelector", + "description": "NodeSelector defines the nodes where the device is available.\n\nMust use exactly one term.\n\nMust only be set if Spec.PerDeviceNodeSelection is set to true. At most one of NodeName, NodeSelector and AllNodes can be set." + }, + "taints": { + "description": "If specified, these are the driver-defined taints.\n\nThe maximum number of taints is 4.\n\nThis is an alpha field and requires enabling the DRADeviceTaints feature gate.", + "items": { + "$ref": "#/definitions/v1.DeviceTaint" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "required": [ - "spec" + "name" ], - "type": "object", - "x-kubernetes-group-version-kind": [ - { - "group": "storage.k8s.io", - "kind": "CSIDriver", - "version": "v1" - } - ] + "type": "object" }, - "v1.CSIDriverList": { - "description": "CSIDriverList is a collection of CSIDriver objects.", + "v1.DeviceAllocationConfiguration": { + "description": "DeviceAllocationConfiguration gets embedded in an AllocationResult.", "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" + "opaque": { + "$ref": "#/definitions/v1.OpaqueDeviceConfiguration", + "description": "Opaque provides driver-specific configuration parameters." }, - "items": { - "description": "items is the list of CSIDriver", + "requests": { + "description": "Requests lists the names of requests where the configuration applies. If empty, its applies to all requests.\n\nReferences to subrequests must include the name of the main request and may include the subrequest using the format
[/]. If just the main request is given, the configuration applies to all subrequests.", "items": { - "$ref": "#/definitions/v1.CSIDriver" + "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "source": { + "description": "Source records whether the configuration comes from a class and thus is not something that a normal user would have been able to set or from a claim.", "type": "string" - }, - "metadata": { - "$ref": "#/definitions/v1.ListMeta", - "description": "Standard list metadata More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" } }, "required": [ - "items" + "source" ], - "type": "object", - "x-kubernetes-group-version-kind": [ - { - "group": "storage.k8s.io", - "kind": "CSIDriverList", - "version": "v1" + "type": "object" + }, + "v1.DeviceAllocationResult": { + "description": "DeviceAllocationResult is the result of allocating devices.", + "properties": { + "config": { + "description": "This field is a combination of all the claim and class configuration parameters. Drivers can distinguish between those based on a flag.\n\nThis includes configuration parameters for drivers which have no allocated devices in the result because it is up to the drivers which configuration parameters they support. They can silently ignore unknown configuration parameters.", + "items": { + "$ref": "#/definitions/v1.DeviceAllocationConfiguration" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "results": { + "description": "Results lists all allocated devices.", + "items": { + "$ref": "#/definitions/v1.DeviceRequestAllocationResult" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" } - ] + }, + "type": "object" }, - "v1.CSIDriverSpec": { - "description": "CSIDriverSpec is the specification of a CSIDriver.", + "v1.DeviceAttribute": { + "description": "DeviceAttribute must have exactly one field set.", "properties": { - "attachRequired": { - "description": "attachRequired indicates this CSI volume driver requires an attach operation (because it implements the CSI ControllerPublishVolume() method), and that the Kubernetes attach detach controller should call the attach volume interface which checks the volumeattachment status and waits until the volume is attached before proceeding to mounting. The CSI external-attacher coordinates with CSI volume driver and updates the volumeattachment status when the attach operation is complete. If the CSIDriverRegistry feature gate is enabled and the value is specified to false, the attach operation will be skipped. Otherwise the attach operation will be called.\n\nThis field is immutable.", + "bool": { + "description": "BoolValue is a true/false value.", "type": "boolean" }, - "fsGroupPolicy": { - "description": "Defines if the underlying volume supports changing ownership and permission of the volume before being mounted. Refer to the specific FSGroupPolicy values for additional details.\n\nThis field is immutable.\n\nDefaults to ReadWriteOnceWithFSType, which will examine each volume to determine if Kubernetes should modify ownership and permissions of the volume. With the default policy the defined fsGroup will only be applied if a fstype is defined and the volume's access mode contains ReadWriteOnce.", - "type": "string" + "int": { + "description": "IntValue is a number.", + "format": "int64", + "type": "integer" }, - "podInfoOnMount": { - "description": "If set to true, podInfoOnMount indicates this CSI volume driver requires additional pod information (like podName, podUID, etc.) during mount operations. If set to false, pod information will not be passed on mount. Default is false. The CSI driver specifies podInfoOnMount as part of driver deployment. If true, Kubelet will pass pod information as VolumeContext in the CSI NodePublishVolume() calls. The CSI driver is responsible for parsing and validating the information passed in as VolumeContext. The following VolumeConext will be passed if podInfoOnMount is set to true. This list might grow, but the prefix will be used. \"csi.storage.k8s.io/pod.name\": pod.Name \"csi.storage.k8s.io/pod.namespace\": pod.Namespace \"csi.storage.k8s.io/pod.uid\": string(pod.UID) \"csi.storage.k8s.io/ephemeral\": \"true\" if the volume is an ephemeral inline volume\n defined by a CSIVolumeSource, otherwise \"false\"\n\n\"csi.storage.k8s.io/ephemeral\" is a new feature in Kubernetes 1.16. It is only required for drivers which support both the \"Persistent\" and \"Ephemeral\" VolumeLifecycleMode. Other drivers can leave pod info disabled and/or ignore this field. As Kubernetes 1.15 doesn't support this field, drivers can only support one mode when deployed on such a cluster and the deployment determines which mode that is, for example via a command line parameter of the driver.\n\nThis field is immutable.", - "type": "boolean" + "string": { + "description": "StringValue is a string. Must not be longer than 64 characters.", + "type": "string" }, - "requiresRepublish": { - "description": "RequiresRepublish indicates the CSI driver wants `NodePublishVolume` being periodically called to reflect any possible change in the mounted volume. This field defaults to false.\n\nNote: After a successful initial NodePublishVolume call, subsequent calls to NodePublishVolume should only update the contents of the volume. New mount points will not be seen by a running container.", - "type": "boolean" + "version": { + "description": "VersionValue is a semantic version according to semver.org spec 2.0.0. Must not be longer than 64 characters.", + "type": "string" + } + }, + "type": "object" + }, + "v1.DeviceCapacity": { + "description": "DeviceCapacity describes a quantity associated with a device.", + "properties": { + "requestPolicy": { + "$ref": "#/definitions/v1.CapacityRequestPolicy", + "description": "RequestPolicy defines how this DeviceCapacity must be consumed when the device is allowed to be shared by multiple allocations.\n\nThe Device must have allowMultipleAllocations set to true in order to set a requestPolicy.\n\nIf unset, capacity requests are unconstrained: requests can consume any amount of capacity, as long as the total consumed across all allocations does not exceed the device's defined capacity. If request is also unset, default is the full capacity value." }, - "seLinuxMount": { - "description": "SELinuxMount specifies if the CSI driver supports \"-o context\" mount option.\n\nWhen \"true\", the CSI driver must ensure that all volumes provided by this CSI driver can be mounted separately with different `-o context` options. This is typical for storage backends that provide volumes as filesystems on block devices or as independent shared volumes. Kubernetes will call NodeStage / NodePublish with \"-o context=xyz\" mount option when mounting a ReadWriteOncePod volume used in Pod that has explicitly set SELinux context. In the future, it may be expanded to other volume AccessModes. In any case, Kubernetes will ensure that the volume is mounted only with a single SELinux context.\n\nWhen \"false\", Kubernetes won't pass any special SELinux mount options to the driver. This is typical for volumes that represent subdirectories of a bigger shared filesystem.\n\nDefault is \"false\".", - "type": "boolean" + "value": { + "$ref": "#/definitions/resource.Quantity", + "description": "Value defines how much of a certain capacity that device has.\n\nThis field reflects the fixed total capacity and does not change. The consumed amount is tracked separately by scheduler and does not affect this value." + } + }, + "required": [ + "value" + ], + "type": "object" + }, + "v1.DeviceClaim": { + "description": "DeviceClaim defines how to request devices with a ResourceClaim.", + "properties": { + "config": { + "description": "This field holds configuration for multiple potential drivers which could satisfy requests in this claim. It is ignored while allocating the claim.", + "items": { + "$ref": "#/definitions/v1.DeviceClaimConfiguration" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" }, - "storageCapacity": { - "description": "If set to true, storageCapacity indicates that the CSI volume driver wants pod scheduling to consider the storage capacity that the driver deployment will report by creating CSIStorageCapacity objects with capacity information.\n\nThe check can be enabled immediately when deploying a driver. In that case, provisioning new volumes with late binding will pause until the driver deployment has published some suitable CSIStorageCapacity object.\n\nAlternatively, the driver can be deployed with the field unset or false and it can be flipped later when storage capacity information has been published.\n\nThis field was immutable in Kubernetes <= 1.22 and now is mutable.", - "type": "boolean" + "constraints": { + "description": "These constraints must be satisfied by the set of devices that get allocated for the claim.", + "items": { + "$ref": "#/definitions/v1.DeviceConstraint" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" }, - "tokenRequests": { - "description": "TokenRequests indicates the CSI driver needs pods' service account tokens it is mounting volume for to do necessary authentication. Kubelet will pass the tokens in VolumeContext in the CSI NodePublishVolume calls. The CSI driver should parse and validate the following VolumeContext: \"csi.storage.k8s.io/serviceAccount.tokens\": {\n \"\": {\n \"token\": ,\n \"expirationTimestamp\": ,\n },\n ...\n}\n\nNote: Audience in each TokenRequest should be different and at most one token is empty string. To receive a new token after expiry, RequiresRepublish can be used to trigger NodePublishVolume periodically.", + "requests": { + "description": "Requests represent individual requests for distinct devices which must all be satisfied. If empty, nothing needs to be allocated.", "items": { - "$ref": "#/definitions/storage.v1.TokenRequest" + "$ref": "#/definitions/v1.DeviceRequest" }, "type": "array", "x-kubernetes-list-type": "atomic" + } + }, + "type": "object" + }, + "v1.DeviceClaimConfiguration": { + "description": "DeviceClaimConfiguration is used for configuration parameters in DeviceClaim.", + "properties": { + "opaque": { + "$ref": "#/definitions/v1.OpaqueDeviceConfiguration", + "description": "Opaque provides driver-specific configuration parameters." }, - "volumeLifecycleModes": { - "description": "volumeLifecycleModes defines what kind of volumes this CSI volume driver supports. The default if the list is empty is \"Persistent\", which is the usage defined by the CSI specification and implemented in Kubernetes via the usual PV/PVC mechanism. The other mode is \"Ephemeral\". In this mode, volumes are defined inline inside the pod spec with CSIVolumeSource and their lifecycle is tied to the lifecycle of that pod. A driver has to be aware of this because it is only going to get a NodePublishVolume call for such a volume. For more information about implementing this mode, see https://kubernetes-csi.github.io/docs/ephemeral-local-volumes.html A driver can support one or more of these modes and more modes may be added in the future. This field is beta.\n\nThis field is immutable.", + "requests": { + "description": "Requests lists the names of requests where the configuration applies. If empty, it applies to all requests.\n\nReferences to subrequests must include the name of the main request and may include the subrequest using the format
[/]. If just the main request is given, the configuration applies to all subrequests.", "items": { "type": "string" }, "type": "array", - "x-kubernetes-list-type": "set" + "x-kubernetes-list-type": "atomic" } }, "type": "object" }, - "v1.CSINode": { - "description": "CSINode holds information about all CSI drivers installed on a node. CSI drivers do not need to create the CSINode object directly. As long as they use the node-driver-registrar sidecar container, the kubelet will automatically populate the CSINode object for the CSI driver as part of kubelet plugin registration. CSINode has the same name as a node. If the object is missing, it means either there are no CSI Drivers available on the node, or the Kubelet version is low enough that it doesn't create this object. CSINode has an OwnerReference that points to the corresponding node object.", + "v1.DeviceClass": { + "description": "DeviceClass is a vendor- or admin-provided resource that contains device configuration and selectors. It can be referenced in the device requests of a claim to apply these presets. Cluster scoped.\n\nThis is an alpha type and requires enabling the DynamicResourceAllocation feature gate.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", @@ -13100,11 +15652,11 @@ }, "metadata": { "$ref": "#/definitions/v1.ObjectMeta", - "description": "metadata.name must be the Kubernetes node name." + "description": "Standard object metadata" }, "spec": { - "$ref": "#/definitions/v1.CSINodeSpec", - "description": "spec is the specification of CSINode" + "$ref": "#/definitions/v1.DeviceClassSpec", + "description": "Spec defines what can be allocated and how to configure it.\n\nThis is mutable. Consumers have to be prepared for classes changing at any time, either because they get updated or replaced. Claim allocations are done once based on whatever was set in classes at the time of allocation.\n\nChanging the spec automatically increments the metadata.generation number." } }, "required": [ @@ -13113,52 +15665,33 @@ "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "storage.k8s.io", - "kind": "CSINode", + "group": "resource.k8s.io", + "kind": "DeviceClass", "version": "v1" } ] }, - "v1.CSINodeDriver": { - "description": "CSINodeDriver holds information about the specification of one CSI driver installed on a node", + "v1.DeviceClassConfiguration": { + "description": "DeviceClassConfiguration is used in DeviceClass.", "properties": { - "allocatable": { - "$ref": "#/definitions/v1.VolumeNodeResources", - "description": "allocatable represents the volume resources of a node that are available for scheduling. This field is beta." - }, - "name": { - "description": "This is the name of the CSI driver that this object refers to. This MUST be the same name returned by the CSI GetPluginName() call for that driver.", - "type": "string" - }, - "nodeID": { - "description": "nodeID of the node from the driver point of view. This field enables Kubernetes to communicate with storage systems that do not share the same nomenclature for nodes. For example, Kubernetes may refer to a given node as \"node1\", but the storage system may refer to the same node as \"nodeA\". When Kubernetes issues a command to the storage system to attach a volume to a specific node, it can use this field to refer to the node name using the ID that the storage system will understand, e.g. \"nodeA\" instead of \"node1\". This field is required.", - "type": "string" - }, - "topologyKeys": { - "description": "topologyKeys is the list of keys supported by the driver. When a driver is initialized on a cluster, it provides a set of topology keys that it understands (e.g. \"company.com/zone\", \"company.com/region\"). When a driver is initialized on a node, it provides the same topology keys along with values. Kubelet will expose these topology keys as labels on its own node object. When Kubernetes does topology aware provisioning, it can use this list to determine which labels it should retrieve from the node object and pass back to the driver. It is possible for different nodes to use different topology keys. This can be empty if driver does not support topology.", - "items": { - "type": "string" - }, - "type": "array" + "opaque": { + "$ref": "#/definitions/v1.OpaqueDeviceConfiguration", + "description": "Opaque provides driver-specific configuration parameters." } }, - "required": [ - "name", - "nodeID" - ], "type": "object" }, - "v1.CSINodeList": { - "description": "CSINodeList is a collection of CSINode objects.", + "v1.DeviceClassList": { + "description": "DeviceClassList is a collection of classes.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", "type": "string" }, "items": { - "description": "items is the list of CSINode", + "description": "Items is the list of resource classes.", "items": { - "$ref": "#/definitions/v1.CSINode" + "$ref": "#/definitions/v1.DeviceClass" }, "type": "array" }, @@ -13168,7 +15701,7 @@ }, "metadata": { "$ref": "#/definitions/v1.ListMeta", - "description": "Standard list metadata More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + "description": "Standard list metadata" } }, "required": [ @@ -13177,234 +15710,372 @@ "type": "object", "x-kubernetes-group-version-kind": [ { - "group": "storage.k8s.io", - "kind": "CSINodeList", + "group": "resource.k8s.io", + "kind": "DeviceClassList", "version": "v1" } ] }, - "v1.CSINodeSpec": { - "description": "CSINodeSpec holds information about the specification of all CSI drivers installed on a node", + "v1.DeviceClassSpec": { + "description": "DeviceClassSpec is used in a [DeviceClass] to define what can be allocated and how to configure it.", "properties": { - "drivers": { - "description": "drivers is a list of information of all CSI Drivers existing on a node. If all drivers in the list are uninstalled, this can become empty.", + "config": { + "description": "Config defines configuration parameters that apply to each device that is claimed via this class. Some classses may potentially be satisfied by multiple drivers, so each instance of a vendor configuration applies to exactly one driver.\n\nThey are passed to the driver, but are not considered while allocating the claim.", "items": { - "$ref": "#/definitions/v1.CSINodeDriver" + "$ref": "#/definitions/v1.DeviceClassConfiguration" }, "type": "array", - "x-kubernetes-patch-merge-key": "name", - "x-kubernetes-patch-strategy": "merge" + "x-kubernetes-list-type": "atomic" + }, + "extendedResourceName": { + "description": "ExtendedResourceName is the extended resource name for the devices of this class. The devices of this class can be used to satisfy a pod's extended resource requests. It has the same format as the name of a pod's extended resource. It should be unique among all the device classes in a cluster. If two device classes have the same name, then the class created later is picked to satisfy a pod's extended resource requests. If two classes are created at the same time, then the name of the class lexicographically sorted first is picked.\n\nThis is an alpha field.", + "type": "string" + }, + "selectors": { + "description": "Each selector must be satisfied by a device which is claimed via this class.", + "items": { + "$ref": "#/definitions/v1.DeviceSelector" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" } }, - "required": [ - "drivers" - ], "type": "object" }, - "v1.CSIStorageCapacity": { - "description": "CSIStorageCapacity stores the result of one CSI GetCapacity call. For a given StorageClass, this describes the available capacity in a particular topology segment. This can be used when considering where to instantiate new PersistentVolumes.\n\nFor example this can express things like: - StorageClass \"standard\" has \"1234 GiB\" available in \"topology.kubernetes.io/zone=us-east1\" - StorageClass \"localssd\" has \"10 GiB\" available in \"kubernetes.io/hostname=knode-abc123\"\n\nThe following three cases all imply that no capacity is available for a certain combination: - no object exists with suitable topology and storage class name - such an object exists, but the capacity is unset - such an object exists, but the capacity is zero\n\nThe producer of these objects can decide which approach is more suitable.\n\nThey are consumed by the kube-scheduler when a CSI driver opts into capacity-aware scheduling with CSIDriverSpec.StorageCapacity. The scheduler compares the MaximumVolumeSize against the requested size of pending volumes to filter out unsuitable nodes. If MaximumVolumeSize is unset, it falls back to a comparison against the less precise Capacity. If that is also unset, the scheduler assumes that capacity is insufficient and tries some other node.", + "v1.DeviceConstraint": { + "description": "DeviceConstraint must have exactly one field set besides Requests.", "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "distinctAttribute": { + "description": "DistinctAttribute requires that all devices in question have this attribute and that its type and value are unique across those devices.\n\nThis acts as the inverse of MatchAttribute.\n\nThis constraint is used to avoid allocating multiple requests to the same device by ensuring attribute-level differentiation.\n\nThis is useful for scenarios where resource requests must be fulfilled by separate physical devices. For example, a container requests two network interfaces that must be allocated from two different physical NICs.", "type": "string" }, - "capacity": { - "$ref": "#/definitions/resource.Quantity", - "description": "Capacity is the value reported by the CSI driver in its GetCapacityResponse for a GetCapacityRequest with topology and parameters that match the previous fields.\n\nThe semantic is currently (CSI spec 1.2) defined as: The available capacity, in bytes, of the storage that can be used to provision volumes. If not set, that information is currently unavailable." - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "matchAttribute": { + "description": "MatchAttribute requires that all devices in question have this attribute and that its type and value are the same across those devices.\n\nFor example, if you specified \"dra.example.com/numa\" (a hypothetical example!), then only devices in the same NUMA node will be chosen. A device which does not have that attribute will not be chosen. All devices should use a value of the same type for this attribute because that is part of its specification, but if one device doesn't, then it also will not be chosen.\n\nMust include the domain qualifier.", "type": "string" }, - "maximumVolumeSize": { - "$ref": "#/definitions/resource.Quantity", - "description": "MaximumVolumeSize is the value reported by the CSI driver in its GetCapacityResponse for a GetCapacityRequest with topology and parameters that match the previous fields.\n\nThis is defined since CSI spec 1.4.0 as the largest size that may be used in a CreateVolumeRequest.capacity_range.required_bytes field to create a volume with the same parameters as those in GetCapacityRequest. The corresponding value in the Kubernetes API is ResourceRequirements.Requests in a volume claim." - }, - "metadata": { - "$ref": "#/definitions/v1.ObjectMeta", - "description": "Standard object's metadata. The name has no particular meaning. It must be be a DNS subdomain (dots allowed, 253 characters). To ensure that there are no conflicts with other CSI drivers on the cluster, the recommendation is to use csisc-, a generated name, or a reverse-domain name which ends with the unique CSI driver name.\n\nObjects are namespaced.\n\nMore info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" - }, - "nodeTopology": { - "$ref": "#/definitions/v1.LabelSelector", - "description": "NodeTopology defines which nodes have access to the storage for which capacity was reported. If not set, the storage is not accessible from any node in the cluster. If empty, the storage is accessible from all nodes. This field is immutable." - }, - "storageClassName": { - "description": "The name of the StorageClass that the reported capacity applies to. It must meet the same requirements as the name of a StorageClass object (non-empty, DNS subdomain). If that object no longer exists, the CSIStorageCapacity object is obsolete and should be removed by its creator. This field is immutable.", + "requests": { + "description": "Requests is a list of the one or more requests in this claim which must co-satisfy this constraint. If a request is fulfilled by multiple devices, then all of the devices must satisfy the constraint. If this is not specified, this constraint applies to all requests in this claim.\n\nReferences to subrequests must include the name of the main request and may include the subrequest using the format
[/]. If just the main request is given, the constraint applies to all subrequests.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + } + }, + "type": "object" + }, + "v1.DeviceCounterConsumption": { + "description": "DeviceCounterConsumption defines a set of counters that a device will consume from a CounterSet.", + "properties": { + "counterSet": { + "description": "CounterSet is the name of the set from which the counters defined will be consumed.", "type": "string" + }, + "counters": { + "additionalProperties": { + "$ref": "#/definitions/v1.Counter" + }, + "description": "Counters defines the counters that will be consumed by the device.\n\nThe maximum number counters in a device is 32. In addition, the maximum number of all counters in all devices is 1024 (for example, 64 devices with 16 counters each).", + "type": "object" } }, "required": [ - "storageClassName" + "counterSet", + "counters" ], - "type": "object", - "x-kubernetes-group-version-kind": [ - { - "group": "storage.k8s.io", - "kind": "CSIStorageCapacity", - "version": "v1" - } - ] + "type": "object" }, - "v1.CSIStorageCapacityList": { - "description": "CSIStorageCapacityList is a collection of CSIStorageCapacity objects.", + "v1.DeviceRequest": { + "description": "DeviceRequest is a request for devices required for a claim. This is typically a request for a single resource like a device, but can also ask for several identical devices. With FirstAvailable it is also possible to provide a prioritized list of requests.", "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" + "exactly": { + "$ref": "#/definitions/v1.ExactDeviceRequest", + "description": "Exactly specifies the details for a single request that must be met exactly for the request to be satisfied.\n\nOne of Exactly or FirstAvailable must be set." }, - "items": { - "description": "Items is the list of CSIStorageCapacity objects.", + "firstAvailable": { + "description": "FirstAvailable contains subrequests, of which exactly one will be selected by the scheduler. It tries to satisfy them in the order in which they are listed here. So if there are two entries in the list, the scheduler will only check the second one if it determines that the first one can not be used.\n\nDRA does not yet implement scoring, so the scheduler will select the first set of devices that satisfies all the requests in the claim. And if the requirements can be satisfied on more than one node, other scheduling features will determine which node is chosen. This means that the set of devices allocated to a claim might not be the optimal set available to the cluster. Scoring will be implemented later.", "items": { - "$ref": "#/definitions/v1.CSIStorageCapacity" + "$ref": "#/definitions/v1.DeviceSubRequest" }, "type": "array", - "x-kubernetes-list-map-keys": [ - "name" - ], - "x-kubernetes-list-type": "map" + "x-kubernetes-list-type": "atomic" }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "name": { + "description": "Name can be used to reference this request in a pod.spec.containers[].resources.claims entry and in a constraint of the claim.\n\nReferences using the name in the DeviceRequest will uniquely identify a request when the Exactly field is set. When the FirstAvailable field is set, a reference to the name of the DeviceRequest will match whatever subrequest is chosen by the scheduler.\n\nMust be a DNS label.", "type": "string" - }, - "metadata": { - "$ref": "#/definitions/v1.ListMeta", - "description": "Standard list metadata More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" } }, "required": [ - "items" + "name" ], - "type": "object", - "x-kubernetes-group-version-kind": [ - { - "group": "storage.k8s.io", - "kind": "CSIStorageCapacityList", - "version": "v1" - } - ] + "type": "object" }, - "v1.StorageClass": { - "description": "StorageClass describes the parameters for a class of storage for which PersistentVolumes can be dynamically provisioned.\n\nStorageClasses are non-namespaced; the name of the storage class according to etcd is in ObjectMeta.Name.", + "v1.DeviceRequestAllocationResult": { + "description": "DeviceRequestAllocationResult contains the allocation result for one request.", "properties": { - "allowVolumeExpansion": { - "description": "AllowVolumeExpansion shows whether the storage class allow volume expand", + "adminAccess": { + "description": "AdminAccess indicates that this device was allocated for administrative access. See the corresponding request field for a definition of mode.\n\nThis is an alpha field and requires enabling the DRAAdminAccess feature gate. Admin access is disabled if this field is unset or set to false, otherwise it is enabled.", "type": "boolean" }, - "allowedTopologies": { - "description": "Restrict the node topologies where volumes can be dynamically provisioned. Each volume plugin defines its own supported topology specifications. An empty TopologySelectorTerm list means there is no topology restriction. This field is only honored by servers that enable the VolumeScheduling feature.", + "bindingConditions": { + "description": "BindingConditions contains a copy of the BindingConditions from the corresponding ResourceSlice at the time of allocation.\n\nThis is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus feature gates.", "items": { - "$ref": "#/definitions/v1.TopologySelectorTerm" + "type": "string" }, "type": "array", "x-kubernetes-list-type": "atomic" }, - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "metadata": { - "$ref": "#/definitions/v1.ObjectMeta", - "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" - }, - "mountOptions": { - "description": "Dynamically provisioned PersistentVolumes of this storage class are created with these mountOptions, e.g. [\"ro\", \"soft\"]. Not validated - mount of the PVs will simply fail if one is invalid.", + "bindingFailureConditions": { + "description": "BindingFailureConditions contains a copy of the BindingFailureConditions from the corresponding ResourceSlice at the time of allocation.\n\nThis is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus feature gates.", "items": { "type": "string" }, - "type": "array" + "type": "array", + "x-kubernetes-list-type": "atomic" }, - "parameters": { + "consumedCapacity": { "additionalProperties": { - "type": "string" + "$ref": "#/definitions/resource.Quantity" }, - "description": "Parameters holds the parameters for the provisioner that should create volumes of this storage class.", + "description": "ConsumedCapacity tracks the amount of capacity consumed per device as part of the claim request. The consumed amount may differ from the requested amount: it is rounded up to the nearest valid value based on the device\u2019s requestPolicy if applicable (i.e., may not be less than the requested amount).\n\nThe total consumed capacity for each device must not exceed the DeviceCapacity's Value.\n\nThis field is populated only for devices that allow multiple allocations. All capacity entries are included, even if the consumed amount is zero.", "type": "object" }, - "provisioner": { - "description": "Provisioner indicates the type of the provisioner.", + "device": { + "description": "Device references one device instance via its name in the driver's resource pool. It must be a DNS label.", "type": "string" }, - "reclaimPolicy": { - "description": "Dynamically provisioned PersistentVolumes of this storage class are created with this reclaimPolicy. Defaults to Delete.", + "driver": { + "description": "Driver specifies the name of the DRA driver whose kubelet plugin should be invoked to process the allocation once the claim is needed on a node.\n\nMust be a DNS subdomain and should end with a DNS domain owned by the vendor of the driver.", "type": "string" }, - "volumeBindingMode": { - "description": "VolumeBindingMode indicates how PersistentVolumeClaims should be provisioned and bound. When unset, VolumeBindingImmediate is used. This field is only honored by servers that enable the VolumeScheduling feature.", + "pool": { + "description": "This name together with the driver name and the device name field identify which device was allocated (`//`).\n\nMust not be longer than 253 characters and may contain one or more DNS sub-domains separated by slashes.", + "type": "string" + }, + "request": { + "description": "Request is the name of the request in the claim which caused this device to be allocated. If it references a subrequest in the firstAvailable list on a DeviceRequest, this field must include both the name of the main request and the subrequest using the format
/.\n\nMultiple devices may have been allocated per request.", + "type": "string" + }, + "shareID": { + "description": "ShareID uniquely identifies an individual allocation share of the device, used when the device supports multiple simultaneous allocations. It serves as an additional map key to differentiate concurrent shares of the same device.", "type": "string" + }, + "tolerations": { + "description": "A copy of all tolerations specified in the request at the time when the device got allocated.\n\nThe maximum number of tolerations is 16.\n\nThis is an alpha field and requires enabling the DRADeviceTaints feature gate.", + "items": { + "$ref": "#/definitions/v1.DeviceToleration" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "required": [ - "provisioner" + "request", + "driver", + "pool", + "device" ], - "type": "object", - "x-kubernetes-group-version-kind": [ - { - "group": "storage.k8s.io", - "kind": "StorageClass", - "version": "v1" + "type": "object" + }, + "v1.DeviceSelector": { + "description": "DeviceSelector must have exactly one field set.", + "properties": { + "cel": { + "$ref": "#/definitions/v1.CELDeviceSelector", + "description": "CEL contains a CEL expression for selecting a device." } - ] + }, + "type": "object" }, - "v1.StorageClassList": { - "description": "StorageClassList is a collection of storage classes.", + "v1.DeviceSubRequest": { + "description": "DeviceSubRequest describes a request for device provided in the claim.spec.devices.requests[].firstAvailable array. Each is typically a request for a single resource like a device, but can also ask for several identical devices.\n\nDeviceSubRequest is similar to ExactDeviceRequest, but doesn't expose the AdminAccess field as that one is only supported when requesting a specific device.", "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "allocationMode": { + "description": "AllocationMode and its related fields define how devices are allocated to satisfy this subrequest. Supported values are:\n\n- ExactCount: This request is for a specific number of devices.\n This is the default. The exact number is provided in the\n count field.\n\n- All: This subrequest is for all of the matching devices in a pool.\n Allocation will fail if some devices are already allocated,\n unless adminAccess is requested.\n\nIf AllocationMode is not specified, the default mode is ExactCount. If the mode is ExactCount and count is not specified, the default count is one. Any other subrequests must specify this field.\n\nMore modes may get added in the future. Clients must refuse to handle requests with unknown modes.", "type": "string" }, - "items": { - "description": "Items is the list of StorageClasses", - "items": { - "$ref": "#/definitions/v1.StorageClass" - }, - "type": "array" + "capacity": { + "$ref": "#/definitions/v1.CapacityRequirements", + "description": "Capacity define resource requirements against each capacity.\n\nIf this field is unset and the device supports multiple allocations, the default value will be applied to each capacity according to requestPolicy. For the capacity that has no requestPolicy, default is the full capacity value.\n\nApplies to each device allocation. If Count > 1, the request fails if there aren't enough devices that meet the requirements. If AllocationMode is set to All, the request fails if there are devices that otherwise match the request, and have this capacity, with a value >= the requested amount, but which cannot be allocated to this request." }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "count": { + "description": "Count is used only when the count mode is \"ExactCount\". Must be greater than zero. If AllocationMode is ExactCount and this field is not specified, the default is one.", + "format": "int64", + "type": "integer" + }, + "deviceClassName": { + "description": "DeviceClassName references a specific DeviceClass, which can define additional configuration and selectors to be inherited by this subrequest.\n\nA class is required. Which classes are available depends on the cluster.\n\nAdministrators may use this to restrict which devices may get requested by only installing classes with selectors for permitted devices. If users are free to request anything without restrictions, then administrators can create an empty DeviceClass for users to reference.", "type": "string" }, - "metadata": { - "$ref": "#/definitions/v1.ListMeta", - "description": "Standard list metadata More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" + "name": { + "description": "Name can be used to reference this subrequest in the list of constraints or the list of configurations for the claim. References must use the format
/.\n\nMust be a DNS label.", + "type": "string" + }, + "selectors": { + "description": "Selectors define criteria which must be satisfied by a specific device in order for that device to be considered for this subrequest. All selectors must be satisfied for a device to be considered.", + "items": { + "$ref": "#/definitions/v1.DeviceSelector" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" + }, + "tolerations": { + "description": "If specified, the request's tolerations.\n\nTolerations for NoSchedule are required to allocate a device which has a taint with that effect. The same applies to NoExecute.\n\nIn addition, should any of the allocated devices get tainted with NoExecute after allocation and that effect is not tolerated, then all pods consuming the ResourceClaim get deleted to evict them. The scheduler will not let new pods reserve the claim while it has these tainted devices. Once all pods are evicted, the claim will get deallocated.\n\nThe maximum number of tolerations is 16.\n\nThis is an alpha field and requires enabling the DRADeviceTaints feature gate.", + "items": { + "$ref": "#/definitions/v1.DeviceToleration" + }, + "type": "array", + "x-kubernetes-list-type": "atomic" } }, "required": [ - "items" + "name", + "deviceClassName" ], - "type": "object", - "x-kubernetes-group-version-kind": [ - { - "group": "storage.k8s.io", - "kind": "StorageClassList", - "version": "v1" + "type": "object" + }, + "v1.DeviceTaint": { + "description": "The device this taint is attached to has the \"effect\" on any claim which does not tolerate the taint and, through the claim, to pods using the claim.", + "properties": { + "effect": { + "description": "The effect of the taint on claims that do not tolerate the taint and through such claims on the pods using them. Valid effects are NoSchedule and NoExecute. PreferNoSchedule as used for nodes is not valid here.", + "type": "string" + }, + "key": { + "description": "The taint key to be applied to a device. Must be a label name.", + "type": "string" + }, + "timeAdded": { + "description": "TimeAdded represents the time at which the taint was added. Added automatically during create or update if not set.", + "format": "date-time", + "type": "string" + }, + "value": { + "description": "The taint value corresponding to the taint key. Must be a label value.", + "type": "string" } - ] + }, + "required": [ + "key", + "effect" + ], + "type": "object" }, - "storage.v1.TokenRequest": { - "description": "TokenRequest contains parameters of a service account token.", + "v1.DeviceToleration": { + "description": "The ResourceClaim this DeviceToleration is attached to tolerates any taint that matches the triple using the matching operator .", "properties": { - "audience": { - "description": "Audience is the intended audience of the token in \"TokenRequestSpec\". It will default to the audiences of kube apiserver.", + "effect": { + "description": "Effect indicates the taint effect to match. Empty means match all taint effects. When specified, allowed values are NoSchedule and NoExecute.", "type": "string" }, - "expirationSeconds": { - "description": "ExpirationSeconds is the duration of validity of the token in \"TokenRequestSpec\". It has the same default value of \"ExpirationSeconds\" in \"TokenRequestSpec\".", + "key": { + "description": "Key is the taint key that the toleration applies to. Empty means match all taint keys. If the key is empty, operator must be Exists; this combination means to match all values and all keys. Must be a label name.", + "type": "string" + }, + "operator": { + "description": "Operator represents a key's relationship to the value. Valid operators are Exists and Equal. Defaults to Equal. Exists is equivalent to wildcard for value, so that a ResourceClaim can tolerate all taints of a particular category.", + "type": "string" + }, + "tolerationSeconds": { + "description": "TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system. If larger than zero, the time when the pod needs to be evicted is calculated as