rancher / rke

Rancher Kubernetes Engine (RKE), an extremely simple, lightning fast Kubernetes distribution that runs entirely within containers.
Apache License 2.0
3.22k stars 582 forks source link

Cert rotate should not proceed if kube-ca has expired #1974

Closed sowmyav27 closed 4 years ago

sowmyav27 commented 4 years ago

RKE version: v1.1.0-rc16

Type/provider of hosts: (VirtualBox/Bare-metal/AWS/GCE/DO) AWS

cluster.yml file:

nodes:
  - address: <ip-1>
    internal_address: <p-ip-1>
    user: ubuntu
    role: [controlplane,worker,etcd]
    ssh_key_path: <>
  - address: <ip-2>
    internal_address: <p-ip-2>
    user: ubuntu
    role: [controlplane,worker,etcd]
    ssh_key_path: <>
  - address: <ip-3>
    internal_address: <p-ip-3>
    user: ubuntu
    role: [controlplane,worker,etcd]
    ssh_key_path: <>

services:
  etcd:
    snapshot: true
    creation: 6h
    retention: 24h

Steps to Reproduce:

Results:

goroutine 1 [running]: k8s.io/kubernetes/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition.NewREST(0xc0007f0af0, 0x4f6dd40, 0xc000156a20, 0xc000156c48) /workspace/anago-v1.17.4-beta.0.54+12bf0cb73007af/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/etcd.go:56 +0x3c1 k8s.io/kubernetes/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver.completedConfig.New(0xc0008511e0, 0xc000220988, 0x502e420, 0x75682f0, 0x10, 0x0, 0x0) /workspace/anago-v1.17.4-beta.0.54+12bf0cb73007af/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/apiserver.go:147 +0x152b k8s.io/kubernetes/cmd/kube-apiserver/app.createAPIExtensionsServer(0xc000220980, 0x502e420, 0x75682f0, 0x0, 0x4f6d980, 0xc0005e4f90) /workspace/anago-v1.17.4-beta.0.54+12bf0cb73007af/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/cmd/kube-apiserver/app/apiextensions.go:99 +0x59 k8s.io/kubernetes/cmd/kube-apiserver/app.CreateServerChain(0xc00032bb80, 0xc0002a6ea0, 0x449aeca, 0xc, 0xc0006dbc48) /workspace/anago-v1.17.4-beta.0.54+12bf0cb73007af/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/cmd/kube-apiserver/app/server.go:183 +0x292 k8s.io/kubernetes/cmd/kube-apiserver/app.Run(0xc00032bb80, 0xc0002a6ea0, 0x0, 0x0) /workspace/anago-v1.17.4-beta.0.54+12bf0cb73007af/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/cmd/kube-apiserver/app/server.go:152 +0x101 k8s.io/kubernetes/cmd/kube-apiserver/app.NewAPIServerCommand.func1(0xc0002c8500, 0xc00051c480, 0x0, 0x23, 0x0, 0x0) /workspace/anago-v1.17.4-beta.0.54+12bf0cb73007af/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/cmd/kube-apiserver/app/server.go:119 +0x104 k8s.io/kubernetes/vendor/github.com/spf13/cobra.(Command).execute(0xc0002c8500, 0xc0000be010, 0x23, 0x23, 0xc0002c8500, 0xc0000be010) /workspace/anago-v1.17.4-beta.0.54+12bf0cb73007af/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:826 +0x460 k8s.io/kubernetes/vendor/github.com/spf13/cobra.(Command).ExecuteC(0xc0002c8500, 0x15fd30372f0644d7, 0x754a340, 0xc00006a750) /workspace/anago-v1.17.4-beta.0.54+12bf0cb73007af/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:914 +0x2fb k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).Execute(...) /workspace/anago-v1.17.4-beta.0.54+12bf0cb73007af/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:864 main.main() _output/dockerized/go/src/k8s.io/kubernetes/cmd/kube-apiserver/apiserver.go:43 +0xcd

mrajashree commented 4 years ago

@sowmyav27 Can you share the RKE logs?

mrajashree commented 4 years ago

Based on offline discussion with @superseb this happens because we rotate certs even if kube-ca has expired, and that should be avoided

mrajashree commented 4 years ago

Fix available with v1.1.0-rc17

sowmyav27 commented 4 years ago

Verified with rke: v1.1.0-rc17

./rke cert rotate --config rancher-cluster.yml
WARN[0000] This is not an officially supported version (v1.1.0-rc17) of RKE. Please download the latest official release at https://github.com/rancher/rke/releases/latest 
INFO[0000] Running RKE version: v1.1.0-rc17             
INFO[0000] Initiating Kubernetes cluster                
INFO[0000] Rotating Kubernetes cluster certificates     
FATA[0000] Failed to rotate certificates: CA certificate is invalid, please use the --rotate-ca flag to rotate CA certificate, error: x509: certificate has expired or is not yet valid