mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
allow disambiguation of resouces
This commit is contained in:
parent
2b84d58b6d
commit
9c42d219bc
@ -702,7 +702,7 @@ __EOF__
|
|||||||
# Command: autoscale rc "frontend"
|
# Command: autoscale rc "frontend"
|
||||||
kubectl autoscale -f hack/testdata/frontend-controller.yaml --save-config "${kube_flags[@]}" --max=2
|
kubectl autoscale -f hack/testdata/frontend-controller.yaml --save-config "${kube_flags[@]}" --max=2
|
||||||
# Post-Condition: hpa "frontend" has configuration annotation
|
# Post-Condition: hpa "frontend" has configuration annotation
|
||||||
[[ "$(kubectl get hpa frontend -o yaml "${kube_flags[@]}" | grep kubectl.kubernetes.io/last-applied-configuration)" ]]
|
[[ "$(kubectl get hpa.extensions frontend -o yaml "${kube_flags[@]}" | grep kubectl.kubernetes.io/last-applied-configuration)" ]]
|
||||||
# Clean up
|
# Clean up
|
||||||
kubectl delete rc,hpa frontend "${kube_flags[@]}"
|
kubectl delete rc,hpa frontend "${kube_flags[@]}"
|
||||||
|
|
||||||
@ -1191,10 +1191,10 @@ __EOF__
|
|||||||
kube::test::get_object_assert deployment "{{range.items}}{{$id_field}}:{{end}}" 'nginx-deployment:'
|
kube::test::get_object_assert deployment "{{range.items}}{{$id_field}}:{{end}}" 'nginx-deployment:'
|
||||||
# autoscale 2~3 pods, default CPU utilization (80%)
|
# autoscale 2~3 pods, default CPU utilization (80%)
|
||||||
kubectl-with-retry autoscale deployment nginx-deployment "${kube_flags[@]}" --min=2 --max=3
|
kubectl-with-retry autoscale deployment nginx-deployment "${kube_flags[@]}" --min=2 --max=3
|
||||||
kube::test::get_object_assert 'hpa nginx-deployment' "{{$hpa_min_field}} {{$hpa_max_field}} {{$hpa_cpu_field}}" '2 3 80'
|
kube::test::get_object_assert 'hpa.extensions nginx-deployment' "{{$hpa_min_field}} {{$hpa_max_field}} {{$hpa_cpu_field}}" '2 3 80'
|
||||||
# Clean up
|
# Clean up
|
||||||
kubectl delete hpa nginx-deployment "${kube_flags[@]}"
|
kubectl delete hpa nginx-deployment "${kube_flags[@]}"
|
||||||
kubectl delete deployment nginx-deployment "${kube_flags[@]}"
|
kubectl delete deployment.extensions nginx-deployment "${kube_flags[@]}"
|
||||||
|
|
||||||
### Rollback a deployment
|
### Rollback a deployment
|
||||||
# Pre-condition: no deployment exists
|
# Pre-condition: no deployment exists
|
||||||
@ -1209,7 +1209,7 @@ __EOF__
|
|||||||
kube::test::get_object_assert deployment "{{range.items}}{{$deployment_image_field}}:{{end}}" 'nginx:'
|
kube::test::get_object_assert deployment "{{range.items}}{{$deployment_image_field}}:{{end}}" 'nginx:'
|
||||||
# Update the deployment (revision 2)
|
# Update the deployment (revision 2)
|
||||||
kubectl apply -f hack/testdata/deployment-revision2.yaml "${kube_flags[@]}"
|
kubectl apply -f hack/testdata/deployment-revision2.yaml "${kube_flags[@]}"
|
||||||
kube::test::get_object_assert deployment "{{range.items}}{{$deployment_image_field}}:{{end}}" 'nginx:latest:'
|
kube::test::get_object_assert deployment.extensions "{{range.items}}{{$deployment_image_field}}:{{end}}" 'nginx:latest:'
|
||||||
# Rollback to revision 1
|
# Rollback to revision 1
|
||||||
kubectl rollout undo deployment nginx-deployment --to-revision=1 "${kube_flags[@]}"
|
kubectl rollout undo deployment nginx-deployment --to-revision=1 "${kube_flags[@]}"
|
||||||
sleep 1
|
sleep 1
|
||||||
|
@ -46,6 +46,17 @@ func (gr *GroupResource) String() string {
|
|||||||
return gr.Resource + "." + gr.Group
|
return gr.Resource + "." + gr.Group
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ParseGroupResource turns "resource.group" string into a GroupResource struct. Empty strings are allowed
|
||||||
|
// for each field.
|
||||||
|
func ParseGroupResource(gr string) GroupResource {
|
||||||
|
s := strings.SplitN(gr, ".", 2)
|
||||||
|
if len(s) == 1 {
|
||||||
|
return GroupResource{Resource: s[0]}
|
||||||
|
}
|
||||||
|
|
||||||
|
return GroupResource{Group: s[1], Resource: s[0]}
|
||||||
|
}
|
||||||
|
|
||||||
// GroupVersionResource unambiguously identifies a resource. It doesn't anonymously include GroupVersion
|
// GroupVersionResource unambiguously identifies a resource. It doesn't anonymously include GroupVersion
|
||||||
// to avoid automatic coersion. It doesn't use a GroupVersion to avoid custom marshalling
|
// to avoid automatic coersion. It doesn't use a GroupVersion to avoid custom marshalling
|
||||||
//
|
//
|
||||||
|
@ -79,7 +79,7 @@ func RunExplain(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []st
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: We should deduce the group for a resource by discovering the supported resources at server.
|
// TODO: We should deduce the group for a resource by discovering the supported resources at server.
|
||||||
gvk, err := mapper.KindFor(unversioned.GroupVersionResource{Resource: inModel})
|
gvk, err := mapper.KindFor(unversioned.ParseGroupResource(inModel).WithVersion(""))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -440,7 +440,7 @@ func (b *Builder) resourceMappings() ([]*meta.RESTMapping, error) {
|
|||||||
}
|
}
|
||||||
mappings := []*meta.RESTMapping{}
|
mappings := []*meta.RESTMapping{}
|
||||||
for _, r := range b.resources {
|
for _, r := range b.resources {
|
||||||
gvk, err := b.mapper.KindFor(unversioned.GroupVersionResource{Resource: r})
|
gvk, err := b.mapper.KindFor(unversioned.ParseGroupResource(r).WithVersion(""))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -460,7 +460,7 @@ func (b *Builder) resourceTupleMappings() (map[string]*meta.RESTMapping, error)
|
|||||||
if _, ok := mappings[r.Resource]; ok {
|
if _, ok := mappings[r.Resource]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
gvk, err := b.mapper.KindFor(unversioned.GroupVersionResource{Resource: r.Resource})
|
gvk, err := b.mapper.KindFor(unversioned.ParseGroupResource(r.Resource).WithVersion(""))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user