microk8s 上的“microk8s.enable istio”因“字段不可变”而失败

microk8s 上的“microk8s.enable istio”因“字段不可变”而失败

microk8s.enable istiomicrok8s 上的失败是由于field is immutable。相关故障输出为

Error from server (Invalid): error when applying patch:
{"metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"batch/v1\",\"kind\":\"Job\",\"metadata\":{\"annotations\":{\"helm.sh/hook\":\"post-install\",\"helm.sh/hook-delete-policy\":\"hook-succeeded\"},\"labels\":{\"app\":\"istio-grafana\",\"chart\":\"grafana-1.0.5\",\"heritage\":\"Tiller\",\"release\":\"istio\"},\"name\":\"istio-grafana-post-install\",\"namespace\":\"istio-system\"},\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"app\":\"istio-grafana\",\"release\":\"istio\"},\"name\":\"istio-grafana-post-install\"},\"spec\":{\"containers\":[{\"command\":[\"/bin/bash\",\"/tmp/grafana/run.sh\",\"/tmp/grafana/custom-resources.yaml\"],\"image\":\"quay.io/coreos/hyperkube:v1.7.6_coreos.0\",\"name\":\"hyperkube\",\"volumeMounts\":[{\"mountPath\":\"/tmp/grafana\",\"name\":\"tmp-configmap-grafana\"}]}],\"restartPolicy\":\"OnFailure\",\"serviceAccountName\":\"istio-grafana-post-install-account\",\"volumes\":[{\"configMap\":{\"name\":\"istio-grafana-custom-resources\"},\"name\":\"tmp-configmap-grafana\"}]}}}}\n"},"labels":{"chart":"grafana-1.0.5","release":"istio"}},"spec":{"template":{"metadata":{"labels":{"release":"istio"}}}}}
to:
Resource: "batch/v1, Resource=jobs", GroupVersionKind: "batch/v1, Kind=Job"
Name: "istio-grafana-post-install", Namespace: "istio-system"
Object: &{map["apiVersion":"batch/v1" "kind":"Job" "metadata":map["annotations":map["helm.sh/hook":"post-install" "helm.sh/hook-delete-policy":"hook-succeeded" "kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"batch/v1\",\"kind\":\"Job\",\"metadata\":{\"annotations\":{\"helm.sh/hook\":\"post-install\",\"helm.sh/hook-delete-policy\":\"hook-succeeded\"},\"labels\":{\"app\":\"istio-grafana\",\"chart\":\"grafana-0.1.0\",\"heritage\":\"Tiller\",\"release\":\"RELEASE-NAME\"},\"name\":\"istio-grafana-post-install\",\"namespace\":\"istio-system\"},\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"app\":\"istio-grafana\",\"release\":\"RELEASE-NAME\"},\"name\":\"istio-grafana-post-install\"},\"spec\":{\"containers\":[{\"command\":[\"/bin/bash\",\"/tmp/grafana/run.sh\",\"/tmp/grafana/custom-resources.yaml\"],\"image\":\"quay.io/coreos/hyperkube:v1.7.6_coreos.0\",\"name\":\"hyperkube\",\"volumeMounts\":[{\"mountPath\":\"/tmp/grafana\",\"name\":\"tmp-configmap-grafana\"}]}],\"restartPolicy\":\"OnFailure\",\"serviceAccountName\":\"istio-grafana-post-install-account\",\"volumes\":[{\"configMap\":{\"name\":\"istio-grafana-custom-resources\"},\"name\":\"tmp-configmap-grafana\"}]}}}}\n"] "creationTimestamp":"2019-03-06T17:31:59Z" "labels":map["app":"istio-grafana" "chart":"grafana-0.1.0" "heritage":"Tiller" "release":"RELEASE-NAME"] "name":"istio-grafana-post-install" "namespace":"istio-system" "resourceVersion":"1603" "selfLink":"/apis/batch/v1/namespaces/istio-system/jobs/istio-grafana-post-install" "uid":"bf3accfa-4035-11e9-99ce-208984866d4f"] "spec":map["backoffLimit":'\x06' "completions":'\x01' "parallelism":'\x01' "selector":map["matchLabels":map["controller-uid":"bf3accfa-4035-11e9-99ce-208984866d4f"]] "template":map["metadata":map["creationTimestamp":<nil> "labels":map["app":"istio-grafana" "controller-uid":"bf3accfa-4035-11e9-99ce-208984866d4f" "job-name":"istio-grafana-post-install" "release":"RELEASE-NAME"] "name":"istio-grafana-post-install"] "spec":map["containers":[map["command":["/bin/bash" "/tmp/grafana/run.sh" "/tmp/grafana/custom-resources.yaml"] "image":"quay.io/coreos/hyperkube:v1.7.6_coreos.0" "imagePullPolicy":"IfNotPresent" "name":"hyperkube" "resources":map[] "terminationMessagePath":"/dev/termination-log" "terminationMessagePolicy":"File" "volumeMounts":[map["mountPath":"/tmp/grafana" "name":"tmp-configmap-grafana"]]]] "dnsPolicy":"ClusterFirst" "restartPolicy":"OnFailure" "schedulerName":"default-scheduler" "securityContext":map[] "serviceAccount":"istio-grafana-post-install-account" "serviceAccountName":"istio-grafana-post-install-account" "terminationGracePeriodSeconds":'\x1e' "volumes":[map["configMap":map["defaultMode":'\u01a4' "name":"istio-grafana-custom-resources"] "name":"tmp-configmap-grafana"]]]]] "status":map["completionTime":"2019-03-06T17:34:00Z" "conditions":[map["lastProbeTime":"2019-03-06T17:34:00Z" "lastTransitionTime":"2019-03-06T17:34:00Z" "status":"True" "type":"Complete"]] "startTime":"2019-03-06T17:31:59Z" "succeeded":'\x01']]}
for: "/snap/microk8s/483/actions/istio/istio-demo.yaml": Job.batch "istio-grafana-post-install" is invalid: spec.template: Invalid value: core.PodTemplateSpec{ObjectMeta:v1.ObjectMeta{Name:"istio-grafana-post-install", GenerateName:"", Namespace:"", SelfLink:"", UID:"", ResourceVersion:"", Generation:0, CreationTimestamp:v1.Time{Time:time.Time{wall:0x0, ext:0, loc:(*time.Location)(nil)}}, DeletionTimestamp:(*v1.Time)(nil), DeletionGracePeriodSeconds:(*int64)(nil), Labels:map[string]string{"app":"istio-grafana", "controller-uid":"bf3accfa-4035-11e9-99ce-208984866d4f", "job-name":"istio-grafana-post-install", "release":"istio"}, Annotations:map[string]string(nil), OwnerReferences:[]v1.OwnerReference(nil), Initializers:(*v1.Initializers)(nil), Finalizers:[]string(nil), ClusterName:"", ManagedFields:[]v1.ManagedFieldsEntry(nil)}, Spec:core.PodSpec{Volumes:[]core.Volume{core.Volume{Name:"tmp-configmap-grafana", VolumeSource:core.VolumeSource{HostPath:(*core.HostPathVolumeSource)(nil), EmptyDir:(*core.EmptyDirVolumeSource)(nil), GCEPersistentDisk:(*core.GCEPersistentDiskVolumeSource)(nil), AWSElasticBlockStore:(*core.AWSElasticBlockStoreVolumeSource)(nil), GitRepo:(*core.GitRepoVolumeSource)(nil), Secret:(*core.SecretVolumeSource)(nil), NFS:(*core.NFSVolumeSource)(nil), ISCSI:(*core.ISCSIVolumeSource)(nil), Glusterfs:(*core.GlusterfsVolumeSource)(nil), PersistentVolumeClaim:(*core.PersistentVolumeClaimVolumeSource)(nil), RBD:(*core.RBDVolumeSource)(nil), Quobyte:(*core.QuobyteVolumeSource)(nil), FlexVolume:(*core.FlexVolumeSource)(nil), Cinder:(*core.CinderVolumeSource)(nil), CephFS:(*core.CephFSVolumeSource)(nil), Flocker:(*core.FlockerVolumeSource)(nil), DownwardAPI:(*core.DownwardAPIVolumeSource)(nil), FC:(*core.FCVolumeSource)(nil), AzureFile:(*core.AzureFileVolumeSource)(nil), ConfigMap:(*core.ConfigMapVolumeSource)(0xc00c2d6640), VsphereVolume:(*core.VsphereVirtualDiskVolumeSource)(nil), AzureDisk:(*core.AzureDiskVolumeSource)(nil), PhotonPersistentDisk:(*core.PhotonPersistentDiskVolumeSource)(nil), Projected:(*core.ProjectedVolumeSource)(nil), PortworxVolume:(*core.PortworxVolumeSource)(nil), ScaleIO:(*core.ScaleIOVolumeSource)(nil), StorageOS:(*core.StorageOSVolumeSource)(nil), CSI:(*core.CSIVolumeSource)(nil)}}}, InitContainers:[]core.Container(nil), Containers:[]core.Container{core.Container{Name:"hyperkube", Image:"quay.io/coreos/hyperkube:v1.7.6_coreos.0", Command:[]string{"/bin/bash", "/tmp/grafana/run.sh", "/tmp/grafana/custom-resources.yaml"}, Args:[]string(nil), WorkingDir:"", Ports:[]core.ContainerPort(nil), EnvFrom:[]core.EnvFromSource(nil), Env:[]core.EnvVar(nil), Resources:core.ResourceRequirements{Limits:core.ResourceList(nil), Requests:core.ResourceList(nil)}, VolumeMounts:[]core.VolumeMount{core.VolumeMount{Name:"tmp-configmap-grafana", ReadOnly:false, MountPath:"/tmp/grafana", SubPath:"", MountPropagation:(*core.MountPropagationMode)(nil), SubPathExpr:""}}, VolumeDevices:[]core.VolumeDevice(nil), LivenessProbe:(*core.Probe)(nil), ReadinessProbe:(*core.Probe)(nil), Lifecycle:(*core.Lifecycle)(nil), TerminationMessagePath:"/dev/termination-log", TerminationMessagePolicy:"File", ImagePullPolicy:"IfNotPresent", SecurityContext:(*core.SecurityContext)(nil), Stdin:false, StdinOnce:false, TTY:false}}, RestartPolicy:"OnFailure", TerminationGracePeriodSeconds:(*int64)(0xc004976530), ActiveDeadlineSeconds:(*int64)(nil), DNSPolicy:"ClusterFirst", NodeSelector:map[string]string(nil), ServiceAccountName:"istio-grafana-post-install-account", AutomountServiceAccountToken:(*bool)(nil), NodeName:"", SecurityContext:(*core.PodSecurityContext)(0xc00354ccb0), ImagePullSecrets:[]core.LocalObjectReference(nil), Hostname:"", Subdomain:"", Affinity:(*core.Affinity)(nil), SchedulerName:"default-scheduler", Tolerations:[]core.Toleration(nil), HostAliases:[]core.HostAlias(nil), PriorityClassName:"", Priority:(*int32)(nil), DNSConfig:(*core.PodDNSConfig)(nil), ReadinessGates:[]core.PodReadinessGate(nil), RuntimeClassName:(*string)(nil), EnableServiceLinks:(*bool)(nil)}}: field is immutable
Error from server (Invalid): error when applying patch:
{"metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"batch/v1\",\"kind\":\"Job\",\"metadata\":{\"annotations\":{\"helm.sh/hook\":\"post-delete\",\"helm.sh/hook-delete-policy\":\"hook-succeeded\",\"helm.sh/hook-weight\":\"3\"},\"labels\":{\"app\":\"security\",\"chart\":\"security-1.0.5\",\"heritage\":\"Tiller\",\"release\":\"istio\"},\"name\":\"istio-cleanup-secrets\",\"namespace\":\"istio-system\"},\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"app\":\"security\",\"release\":\"istio\"},\"name\":\"istio-cleanup-secrets\"},\"spec\":{\"containers\":[{\"command\":[\"/bin/bash\",\"-c\",\"kubectl get secret --all-namespaces | grep \\\"istio.io/key-and-cert\\\" |  while read -r entry; do\\n  ns=$(echo $entry | awk '{print $1}');\\n  name=$(echo $entry | awk '{print $2}');\\n  kubectl delete secret $name -n $ns;\\ndone\\n\"],\"image\":\"quay.io/coreos/hyperkube:v1.7.6_coreos.0\",\"name\":\"hyperkube\"}],\"restartPolicy\":\"OnFailure\",\"serviceAccountName\":\"istio-cleanup-secrets-service-account\"}}}}\n"},"labels":{"chart":"security-1.0.5","release":"istio"}},"spec":{"template":{"metadata":{"labels":{"release":"istio"}}}}}
to:
Resource: "batch/v1, Resource=jobs", GroupVersionKind: "batch/v1, Kind=Job"
Name: "istio-cleanup-secrets", Namespace: "istio-system"
Object: &{map["apiVersion":"batch/v1" "kind":"Job" "metadata":map["annotations":map["helm.sh/hook":"post-delete" "helm.sh/hook-delete-policy":"hook-succeeded" "helm.sh/hook-weight":"3" "kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"batch/v1\",\"kind\":\"Job\",\"metadata\":{\"annotations\":{\"helm.sh/hook\":\"post-delete\",\"helm.sh/hook-delete-policy\":\"hook-succeeded\",\"helm.sh/hook-weight\":\"3\"},\"labels\":{\"app\":\"security\",\"chart\":\"security-1.0.0\",\"heritage\":\"Tiller\",\"release\":\"RELEASE-NAME\"},\"name\":\"istio-cleanup-secrets\",\"namespace\":\"istio-system\"},\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"app\":\"security\",\"release\":\"RELEASE-NAME\"},\"name\":\"istio-cleanup-secrets\"},\"spec\":{\"containers\":[{\"command\":[\"/bin/bash\",\"-c\",\"kubectl get secret --all-namespaces | grep \\\"istio.io/key-and-cert\\\" |  while read -r entry; do\\n  ns=$(echo $entry | awk '{print $1}');\\n  name=$(echo $entry | awk '{print $2}');\\n  kubectl delete secret $name -n $ns;\\ndone\\n\"],\"image\":\"quay.io/coreos/hyperkube:v1.7.6_coreos.0\",\"name\":\"hyperkube\"}],\"restartPolicy\":\"OnFailure\",\"serviceAccountName\":\"istio-cleanup-secrets-service-account\"}}}}\n"] "creationTimestamp":"2019-03-06T17:31:59Z" "labels":map["app":"security" "chart":"security-1.0.0" "heritage":"Tiller" "release":"RELEASE-NAME"] "name":"istio-cleanup-secrets" "namespace":"istio-system" "resourceVersion":"1596" "selfLink":"/apis/batch/v1/namespaces/istio-system/jobs/istio-cleanup-secrets" "uid":"bf4f1cdb-4035-11e9-99ce-208984866d4f"] "spec":map["backoffLimit":'\x06' "completions":'\x01' "parallelism":'\x01' "selector":map["matchLabels":map["controller-uid":"bf4f1cdb-4035-11e9-99ce-208984866d4f"]] "template":map["metadata":map["creationTimestamp":<nil> "labels":map["app":"security" "controller-uid":"bf4f1cdb-4035-11e9-99ce-208984866d4f" "job-name":"istio-cleanup-secrets" "release":"RELEASE-NAME"] "name":"istio-cleanup-secrets"] "spec":map["containers":[map["command":["/bin/bash" "-c" "kubectl get secret --all-namespaces | grep \"istio.io/key-and-cert\" |  while read -r entry; do\n  ns=$(echo $entry | awk '{print $1}');\n  name=$(echo $entry | awk '{print $2}');\n  kubectl delete secret $name -n $ns;\ndone\n"] "image":"quay.io/coreos/hyperkube:v1.7.6_coreos.0" "imagePullPolicy":"IfNotPresent" "name":"hyperkube" "resources":map[] "terminationMessagePath":"/dev/termination-log" "terminationMessagePolicy":"File"]] "dnsPolicy":"ClusterFirst" "restartPolicy":"OnFailure" "schedulerName":"default-scheduler" "securityContext":map[] "serviceAccount":"istio-cleanup-secrets-service-account" "serviceAccountName":"istio-cleanup-secrets-service-account" "terminationGracePeriodSeconds":'\x1e']]] "status":map["completionTime":"2019-03-06T17:33:59Z" "conditions":[map["lastProbeTime":"2019-03-06T17:33:59Z" "lastTransitionTime":"2019-03-06T17:33:59Z" "status":"True" "type":"Complete"]] "startTime":"2019-03-06T17:31:59Z" "succeeded":'\x01']]}
for: "/snap/microk8s/483/actions/istio/istio-demo.yaml": Job.batch "istio-cleanup-secrets" is invalid: spec.template: Invalid value: core.PodTemplateSpec{ObjectMeta:v1.ObjectMeta{Name:"istio-cleanup-secrets", GenerateName:"", Namespace:"", SelfLink:"", UID:"", ResourceVersion:"", Generation:0, CreationTimestamp:v1.Time{Time:time.Time{wall:0x0, ext:0, loc:(*time.Location)(nil)}}, DeletionTimestamp:(*v1.Time)(nil), DeletionGracePeriodSeconds:(*int64)(nil), Labels:map[string]string{"app":"security", "controller-uid":"bf4f1cdb-4035-11e9-99ce-208984866d4f", "job-name":"istio-cleanup-secrets", "release":"istio"}, Annotations:map[string]string(nil), OwnerReferences:[]v1.OwnerReference(nil), Initializers:(*v1.Initializers)(nil), Finalizers:[]string(nil), ClusterName:"", ManagedFields:[]v1.ManagedFieldsEntry(nil)}, Spec:core.PodSpec{Volumes:[]core.Volume(nil), InitContainers:[]core.Container(nil), Containers:[]core.Container{core.Container{Name:"hyperkube", Image:"quay.io/coreos/hyperkube:v1.7.6_coreos.0", Command:[]string{"/bin/bash", "-c", "kubectl get secret --all-namespaces | grep \"istio.io/key-and-cert\" |  while read -r entry; do\n  ns=$(echo $entry | awk '{print $1}');\n  name=$(echo $entry | awk '{print $2}');\n  kubectl delete secret $name -n $ns;\ndone\n"}, Args:[]string(nil), WorkingDir:"", Ports:[]core.ContainerPort(nil), EnvFrom:[]core.EnvFromSource(nil), Env:[]core.EnvVar(nil), Resources:core.ResourceRequirements{Limits:core.ResourceList(nil), Requests:core.ResourceList(nil)}, VolumeMounts:[]core.VolumeMount(nil), VolumeDevices:[]core.VolumeDevice(nil), LivenessProbe:(*core.Probe)(nil), ReadinessProbe:(*core.Probe)(nil), Lifecycle:(*core.Lifecycle)(nil), TerminationMessagePath:"/dev/termination-log", TerminationMessagePolicy:"File", ImagePullPolicy:"IfNotPresent", SecurityContext:(*core.SecurityContext)(nil), Stdin:false, StdinOnce:false, TTY:false}}, RestartPolicy:"OnFailure", TerminationGracePeriodSeconds:(*int64)(0xc003271308), ActiveDeadlineSeconds:(*int64)(nil), DNSPolicy:"ClusterFirst", NodeSelector:map[string]string(nil), ServiceAccountName:"istio-cleanup-secrets-service-account", AutomountServiceAccountToken:(*bool)(nil), NodeName:"", SecurityContext:(*core.PodSecurityContext)(0xc00357ca10), ImagePullSecrets:[]core.LocalObjectReference(nil), Hostname:"", Subdomain:"", Affinity:(*core.Affinity)(nil), SchedulerName:"default-scheduler", Tolerations:[]core.Toleration(nil), HostAliases:[]core.HostAlias(nil), PriorityClassName:"", Priority:(*int32)(nil), DNSConfig:(*core.PodDNSConfig)(nil), ReadinessGates:[]core.PodReadinessGate(nil), RuntimeClassName:(*string)(nil), EnableServiceLinks:(*bool)(nil)}}: field is immutable
Failed to enable istio

完整输出可以在以下位置找到:https://pastebin.com/v4CAec14

这似乎与已知问题无关https://github.com/ubuntu/microk8s/issues/414https://github.com/ubuntu/microk8s/issues/386

snap我在 Ubuntu 18.10 上安装稳定版 1.14 (492) 和 edge 1.14.1 (522) 时遇到了这个问题。

答案1

microk8s.disable istio && microk8s.enable istio这已由(我认为我已经尝试过)修复。

相关内容