Enabling Kubernetes PodPresets with kops

I have a kubernetes cluster that was created with kops from 1.5 and then upgraded to 1.6.2. I am trying to use PodPresets. The documents establish the following requirements:

  • You have enabled the api settings.k8s.io/v1alpha1/podpreset
  • You have enabled the PodPreset Access Controller
  • You have defined your package presets

I see that for 1.6.x the first one was taken care of (how can I check?). How can I apply the second? I see that there are three-apiserver- * pods running in the cluster (I think this is for 3 az). I can probably edit their yaml config from kubernetes dashboard and add PodPreset to access control string. But is there a better way to achieve this?

+3


source to share


1 answer


You can specify the API groups that are currently enabled in your cluster, either using the api-versions

kubectl command or by sending a GET request to /apis

your endpoint kube-apiserver

:

$ curl localhost:8080/apis
{
  "paths": [
  "/api",
  "/api/v1",
  "...",
  "/apis/settings.k8s.io",
  "/apis/settings.k8s.io/v1alpha1",
  "...",
}

      

Note . The API is settings.k8s.io/v1alpha1

enabled by default for Kubernetes v1.6 and v1.7, but will be disabled by default in v1.8 .

You can use kops ClusterSpec to tweak the configuration of your Kubernetes components during cluster provisioning, including API servers.

This is documented on the documentation page Using the manifest to manage kops clusters , and the complete specification for the KubeAPIServerConfig type is available in the GoDoc codex .



Example:

apiVersion: kops/v1
kind: Cluster
metadata:
  name: k8s.example.com
spec:
  kubeAPIServer:
    AdmissionControl:
      - NamespaceLifecycle
      - LimitRanger
      - PodPreset

      

To upgrade an existing cluster, follow these steps:

  • Get complete cluster configuration with

    kops get cluster name --full
    
          

  • Copy the kubeAPIServer specification block from it.

  • Don't hit full configuration . Instead, edit your cluster configuration with

    kops edit cluster name
    
          

  • Insert kubeAPIServer spec block, add missing bits and save.

  • Refresh the cluster resources with

    kops update cluster nane
    
          

  • Run the current update to apply the changes:

    kops rolling-update name
    
          

+4


source







All Articles