Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling Kubernetes PodPresets with kops

Tags:

I've got a kubernetes cluster which was set up with kops with 1.5, and then upgraded to 1.6.2. I'm trying to use PodPresets. The docs state the following requirements:

  1. You have enabled the api type settings.k8s.io/v1alpha1/podpreset
  2. You have enabled the admission controller PodPreset
  3. You have defined your pod presets

I'm seeing that for 1.6.x, the first is taken care of (how can I verify?). How can I apply the second? I can see that there are three kube-apiserver-* pods running in the cluster (I imagine it's for the 3 azs). I guess I can edit their yaml config from kubernetes dashboard and add PodPreset to the admission-control string. But is there a better way to achieve this?

like image 677
ashic Avatar asked Jul 02 '17 15:07

ashic


People also ask

How do I enable PodPreset in Kubernetes?

Enable PodPreset in your cluster In order to use Pod presets in your cluster you must ensure the following: You have enabled the API type settings.k8s.io/v1alpha1/podpreset . For example, this can be done by including settings.k8s.io/v1alpha1=true in the --runtime-config option for the API server.

What is the difference between Kubeadm and Kops?

kubeadm installs clusters on existing infrastructure; whereas, kops builds the EC2 instances for you, and can also build VPC, IAM, Security groups and a number of other features as well. If you need HA masters or manifest-based cluster management, then kops may also be your first choice.

What is the difference between Kubectl and Kops?

Kops is sometimes referred to as the 'kubectl' for spinning up clusters. Kops lets you create, destroy and upgrade Kubernetes clusters and is supported on AWS (Amazon Web Services, we cover more of this on our Kubernetes on AWS - what you need to know page) with GKE in beta support, and VMware vSphere in alpha.

What is use of Kops in Kubernetes?

kOps, also known as Kubernetes operations, is an open-source project which helps you create, destroy, upgrade, and maintain a highly available, production-grade Kubernetes cluster. Depending on the requirement, kOps can also provision cloud infrastructure.


1 Answers

You can list the API groups which are currently enabled in your cluster either with the api-versions kubectl command, or by sending a GET request to the /apis endpoint of your kube-apiserver:

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

Note: The settings.k8s.io/v1alpha1 API is enabled by default on Kubernetes v1.6 and v1.7 but will be disabled by default in v1.8.

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

This is described on the documentation page Using A Manifest to Manage kops Clusters, and the full spec for the KubeAPIServerConfig type is available in the kops GoDoc.

Example:

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

To update an existing cluster, perform the following steps:

  1. Get the full cluster configuration with

    kops get cluster name --full
    
  2. Copy the kubeAPIServer spec block from it.

  3. Do not push back the full configuration. Instead, edit the cluster configuration with

    kops edit cluster name
    
  4. Paste the kubeAPIServer spec block, add the missing bits, and save.

  5. Update the cluster resources with

    kops update cluster nane
    
  6. Perform a rolling update to apply the changes:

    kops rolling-update name
    
like image 89
Antoine Cotten Avatar answered Oct 11 '22 14:10

Antoine Cotten