Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
89b0b0b8
Commit
89b0b0b8
authored
Jan 25, 2019
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up initializer-related comments, test data
parent
f5f5d9a5
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
6 additions
and
358 deletions
+6
-358
selfhosting_test.go
cmd/kubeadm/app/phases/selfhosting/selfhosting_test.go
+2
-2
.shellcheck_failures
hack/.shellcheck_failures
+0
-1
initializer-clusterrolebinding.yaml
hack/testdata/initializer-clusterrolebinding.yaml
+0
-17
initializer-deployments.yaml
hack/testdata/initializer-deployments.yaml
+0
-25
initializer-redis-master-service.yaml
hack/testdata/initializer-redis-master-service.yaml
+0
-19
admission_test.go
pkg/kubeapiserver/options/admission_test.go
+2
-2
scale.go
pkg/kubectl/scale.go
+0
-2
strategy.go
.../sample-apiserver/pkg/registry/wardle/fischer/strategy.go
+1
-2
strategy.go
.../sample-apiserver/pkg/registry/wardle/flunder/strategy.go
+1
-2
initializers.sh
test/cmd/initializers.sh
+0
-285
legacy-script.sh
test/cmd/legacy-script.sh
+0
-1
No files found.
cmd/kubeadm/app/phases/selfhosting/selfhosting_test.go
View file @
89b0b0b8
...
...
@@ -58,7 +58,7 @@ spec:
- --requestheader-username-headers=X-Remote-User
- --requestheader-extra-headers-prefix=X-Remote-Extra-
- --requestheader-allowed-names=front-proxy-client
- --admission-control=
Initializers,
NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,ResourceQuota
- --admission-control=NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,ResourceQuota
- --allow-privileged=true
- --client-ca-file=/etc/kubernetes/pki/ca.crt
- --tls-private-key-file=/etc/kubernetes/pki/apiserver.key
...
...
@@ -139,7 +139,7 @@ spec:
- --requestheader-username-headers=X-Remote-User
- --requestheader-extra-headers-prefix=X-Remote-Extra-
- --requestheader-allowed-names=front-proxy-client
- --admission-control=
Initializers,
NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,ResourceQuota
- --admission-control=NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,ResourceQuota
- --allow-privileged=true
- --client-ca-file=/etc/kubernetes/pki/ca.crt
- --tls-private-key-file=/etc/kubernetes/pki/apiserver.key
...
...
hack/.shellcheck_failures
View file @
89b0b0b8
...
...
@@ -200,7 +200,6 @@
./test/cmd/discovery.sh
./test/cmd/generic-resources.sh
./test/cmd/get.sh
./test/cmd/initializers.sh
./test/cmd/legacy-script.sh
./test/cmd/node-management.sh
./test/cmd/old-print.sh
...
...
hack/testdata/initializer-clusterrolebinding.yaml
deleted
100644 → 0
View file @
f5f5d9a5
apiVersion
:
rbac.authorization.k8s.io/v1beta1
kind
:
ClusterRoleBinding
metadata
:
name
:
super-admin
initializers
:
pending
:
-
name
:
podimage.initializer.com
labels
:
clusterrolebinding
:
super
roleRef
:
apiGroup
:
rbac.authorization.k8s.io
kind
:
ClusterRole
name
:
admin
subjects
:
-
apiGroup
:
rbac.authorization.k8s.io
kind
:
User
name
:
super-admin
hack/testdata/initializer-deployments.yaml
deleted
100644 → 0
View file @
f5f5d9a5
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
name
:
web
initializers
:
pending
:
-
name
:
podimage.initializer.com
labels
:
run
:
web
spec
:
replicas
:
5
selector
:
matchLabels
:
run
:
web
template
:
metadata
:
labels
:
run
:
web
spec
:
containers
:
-
image
:
nginx:1.10
name
:
web
ports
:
-
containerPort
:
80
protocol
:
TCP
hack/testdata/initializer-redis-master-service.yaml
deleted
100644 → 0
View file @
f5f5d9a5
apiVersion
:
v1
kind
:
Service
metadata
:
name
:
redis-master
labels
:
app
:
redis
role
:
master
tier
:
backend
initializers
:
pending
:
-
name
:
podimage.initializer.com
spec
:
ports
:
-
port
:
6379
targetPort
:
6379
selector
:
app
:
redis
role
:
master
tier
:
backend
pkg/kubeapiserver/options/admission_test.go
View file @
89b0b0b8
...
...
@@ -25,7 +25,7 @@ func TestValidate(t *testing.T) {
// 1. Both `--admission-control` and `--enable-admission-plugins` are specified
options
:=
NewAdmissionOptions
()
options
.
PluginNames
=
[]
string
{
"ServiceAccount"
}
options
.
GenericAdmission
.
EnablePlugins
=
[]
string
{
"
Initializers
"
}
options
.
GenericAdmission
.
EnablePlugins
=
[]
string
{
"
NodeRestriction
"
}
if
len
(
options
.
Validate
())
==
0
{
t
.
Errorf
(
"Expect error, but got none"
)
}
...
...
@@ -33,7 +33,7 @@ func TestValidate(t *testing.T) {
// 2. Both `--admission-control` and `--disable-admission-plugins` are specified
options
=
NewAdmissionOptions
()
options
.
PluginNames
=
[]
string
{
"ServiceAccount"
}
options
.
GenericAdmission
.
DisablePlugins
=
[]
string
{
"
Initializers
"
}
options
.
GenericAdmission
.
DisablePlugins
=
[]
string
{
"
NodeRestriction
"
}
if
len
(
options
.
Validate
())
==
0
{
t
.
Errorf
(
"Expect error, but got none"
)
}
...
...
pkg/kubectl/scale.go
View file @
89b0b0b8
...
...
@@ -29,8 +29,6 @@ import (
scaleclient
"k8s.io/client-go/scale"
)
// TODO: Figure out if we should be waiting on initializers in the Scale() functions below.
// Scaler provides an interface for resources that can be scaled.
type
Scaler
interface
{
// Scale scales the named resource after checking preconditions. It optionally
...
...
staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer/strategy.go
View file @
89b0b0b8
...
...
@@ -36,8 +36,7 @@ func NewStrategy(typer runtime.ObjectTyper) fischerStrategy {
return
fischerStrategy
{
typer
,
names
.
SimpleNameGenerator
}
}
// GetAttrs returns labels.Set, fields.Set, the presence of Initializers if any
// and error in case the given runtime.Object is not a Fischer
// GetAttrs returns labels.Set, fields.Set, and error in case the given runtime.Object is not a Fischer
func
GetAttrs
(
obj
runtime
.
Object
)
(
labels
.
Set
,
fields
.
Set
,
error
)
{
apiserver
,
ok
:=
obj
.
(
*
wardle
.
Fischer
)
if
!
ok
{
...
...
staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder/strategy.go
View file @
89b0b0b8
...
...
@@ -37,8 +37,7 @@ func NewStrategy(typer runtime.ObjectTyper) flunderStrategy {
return
flunderStrategy
{
typer
,
names
.
SimpleNameGenerator
}
}
// GetAttrs returns labels.Set, fields.Set, the presence of Initializers if any
// and error in case the given runtime.Object is not a Flunder
// GetAttrs returns labels.Set, fields.Set, and error in case the given runtime.Object is not a Flunder
func
GetAttrs
(
obj
runtime
.
Object
)
(
labels
.
Set
,
fields
.
Set
,
error
)
{
apiserver
,
ok
:=
obj
.
(
*
wardle
.
Flunder
)
if
!
ok
{
...
...
test/cmd/initializers.sh
deleted
100755 → 0
View file @
f5f5d9a5
#!/usr/bin/env bash
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set
-o
errexit
set
-o
nounset
set
-o
pipefail
run_initializer_tests
()
{
set
-o
nounset
set
-o
errexit
create_and_use_new_namespace
kube::log::status
"Testing --include-uninitialized"
### Create a deployment
kubectl create
--request-timeout
=
1
-f
hack/testdata/initializer-deployments.yaml 2>&1
"
${
kube_flags
[@]
}
"
||
true
### Test kubectl get --include-uninitialized
# Command
output_message
=
$(
kubectl get deployments 2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "No resources found" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'No resources found'
# Command
output_message
=
$(
kubectl get deployments
--include-uninitialized
=
false
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "No resources found" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'No resources found'
# Command
output_message
=
$(
kubectl get deployments
--include-uninitialized
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: I assume "web" is the deployment name
kube::test::if_has_string
"
${
output_message
}
"
'web'
# Command
output_message
=
$(
kubectl get deployments web 2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: I assume "web" is the deployment name
kube::test::if_has_string
"
${
output_message
}
"
'web'
# Post-condition: The text "No resources found" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'No resources found'
### Test kubectl describe --include-uninitialized
# Command
output_message
=
$(
kubectl describe deployments 2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "run=web" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'run=web'
# Command
output_message
=
$(
kubectl describe deployments
--include-uninitialized
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "run=web" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'run=web'
# Command
output_message
=
$(
kubectl describe deployments
--include-uninitialized
=
false
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The output should be empty
kube::test::if_empty_string
"
${
output_message
}
"
# Command
output_message
=
$(
kubectl describe deployments web
--include-uninitialized
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "run=web" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'run=web'
# Command
output_message
=
$(
kubectl describe deployments web
--include-uninitialized
=
false
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "run=web" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'run=web'
### Test kubectl label --include-uninitialized
# Command
output_message
=
$(
kubectl label deployments
labelkey1
=
labelvalue1
--all
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: web is labelled
kube::test::if_has_string
"
${
output_message
}
"
'deployment "web" labeled'
kube::test::get_object_assert
'deployments web'
"{{
${
labels_field
}
.labelkey1}}"
'labelvalue1'
# Command
output_message
=
$(
kubectl label deployments
labelkey2
=
labelvalue2
--all
--include-uninitialized
=
false
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The output should be empty
kube::test::if_empty_string
"
${
output_message
}
"
# Command
output_message
=
$(
kubectl label deployments
labelkey3
=
labelvalue3
-l
run
=
web 2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The output should be empty
kube::test::if_empty_string
"
${
output_message
}
"
# Command
output_message
=
$(
kubectl label deployments
labelkey4
=
labelvalue4
-l
run
=
web
--include-uninitialized
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: web is labelled
kube::test::if_has_string
"
${
output_message
}
"
'deployment "web" labeled'
kube::test::get_object_assert
'deployments web'
"{{
${
labels_field
}
.labelkey4}}"
'labelvalue4'
# Command
output_message
=
$(
kubectl label deployments
labelkey5
=
labelvalue5
-l
run
=
web
--all
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The output should be empty
kube::test::if_empty_string
"
${
output_message
}
"
# Command
output_message
=
$(
kubectl label deployments
labelkey6
=
labelvalue6
-l
run
=
web
--all
--include-uninitialized
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: web is labelled
kube::test::if_has_string
"
${
output_message
}
"
'deployment "web" labeled'
kube::test::get_object_assert
'deployments web'
"{{
${
labels_field
}
.labelkey6}}"
'labelvalue6'
# Command
output_message
=
$(
kubectl label deployments web
labelkey7
=
labelvalue7 2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: web is labelled
kube::test::if_has_string
"
${
output_message
}
"
'deployment "web" labeled'
kube::test::get_object_assert
'deployments web'
"{{
${
labels_field
}
.labelkey7}}"
'labelvalue7'
# Found All Labels
kube::test::get_object_assert
'deployments web'
"{{
${
labels_field
}
}}"
'map[labelkey1:labelvalue1 labelkey4:labelvalue4 labelkey6:labelvalue6 labelkey7:labelvalue7 run:web]'
### Test kubectl annotate --include-uninitialized
# Command
output_message
=
$(
kubectl annotate deployments
annotatekey1
=
annotatevalue1
--all
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: DEPLOYMENT has annotation
kube::test::if_has_string
"
${
output_message
}
"
'deployment "web" annotated'
kube::test::get_object_assert
'deployments web'
"{{
${
annotations_field
}
.annotatekey1}}"
'annotatevalue1'
# Command
output_message
=
$(
kubectl annotate deployments
annotatekey2
=
annotatevalue2
--all
--include-uninitialized
=
false
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The output should be empty
kube::test::if_empty_string
"
${
output_message
}
"
# Command
output_message
=
$(
kubectl annotate deployments
annotatekey3
=
annotatevalue3
-l
run
=
web 2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The output should be empty
kube::test::if_empty_string
"
${
output_message
}
"
# Command
output_message
=
$(
kubectl annotate deployments
annotatekey4
=
annotatevalue4
-l
run
=
web
--include-uninitialized
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: DEPLOYMENT has annotation
kube::test::if_has_string
"
${
output_message
}
"
'deployment "web" annotated'
kube::test::get_object_assert
'deployments web'
"{{
${
annotations_field
}
.annotatekey4}}"
'annotatevalue4'
# Command
output_message
=
$(
kubectl annotate deployments
annotatekey5
=
annotatevalue5
-l
run
=
web
--all
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The output should be empty
kube::test::if_empty_string
"
${
output_message
}
"
# Command
output_message
=
$(
kubectl annotate deployments
annotatekey6
=
annotatevalue6
-l
run
=
web
--all
--include-uninitialized
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: DEPLOYMENT has annotation
kube::test::if_has_string
"
${
output_message
}
"
'deployment "web" annotated'
kube::test::get_object_assert
'deployments web'
"{{
${
annotations_field
}
.annotatekey6}}"
'annotatevalue6'
# Command
output_message
=
$(
kubectl annotate deployments web
annotatekey7
=
annotatevalue7 2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: web DEPLOYMENT has annotation
kube::test::if_has_string
"
${
output_message
}
"
'deployment "web" annotated'
kube::test::get_object_assert
'deployments web'
"{{
${
annotations_field
}
.annotatekey7}}"
'annotatevalue7'
### Test kubectl edit --include-uninitialized
[
"
$(
EDITOR
=
cat
kubectl edit deployments 2>&1
"
${
kube_flags
[@]
}
"
|
grep
'edit cancelled, no objects found'
)
"
]
[
"
$(
EDITOR
=
cat
kubectl edit deployments
--include-uninitialized
2>&1
"
${
kube_flags
[@]
}
"
|
grep
'Edit cancelled, no changes made.'
)
"
]
### Test kubectl set image --include-uninitialized
# Command
output_message
=
$(
kubectl
set
image deployments
*
=
nginx:1.11
--all
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "image updated" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'image updated'
# Command
output_message
=
$(
kubectl
set
image deployments
*
=
nginx:1.11
--all
--include-uninitialized
=
false
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The output should be empty
kube::test::if_empty_string
"
${
output_message
}
"
# Command
output_message
=
$(
kubectl
set
image deployments
*
=
nginx:1.11
-l
run
=
web 2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The output should be empty
kube::test::if_empty_string
"
${
output_message
}
"
# Command
output_message
=
$(
kubectl
set
image deployments
*
=
nginx:1.12
-l
run
=
web
--include-uninitialized
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "image updated" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'image updated'
# Command
output_message
=
$(
kubectl
set
image deployments
*
=
nginx:1.13
-l
run
=
web
--include-uninitialized
--all
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "image updated" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'image updated'
### Test kubectl set resources --include-uninitialized
# Command
output_message
=
$(
kubectl
set
resources deployments
--limits
=
cpu
=
200m,memory
=
512Mi
--requests
=
cpu
=
100m,memory
=
256Mi
--all
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "resource requirements updated" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'resource requirements updated'
# Command
output_message
=
$(
kubectl
set
resources deployments
--limits
=
cpu
=
200m,memory
=
512Mi
--requests
=
cpu
=
100m,memory
=
256Mi
--all
--include-uninitialized
=
false
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The output should be empty
kube::test::if_empty_string
"
${
output_message
}
"
# Command
output_message
=
$(
kubectl
set
resources deployments
--limits
=
cpu
=
200m,memory
=
512Mi
--requests
=
cpu
=
100m,memory
=
256Mi
-l
run
=
web 2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The output should be empty
kube::test::if_empty_string
"
${
output_message
}
"
# Command
output_message
=
$(
kubectl
set
resources deployments
--limits
=
cpu
=
200m,memory
=
512Mi
--requests
=
cpu
=
200m,memory
=
256Mi
-l
run
=
web
--include-uninitialized
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "resource requirements updated" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'resource requirements updated'
# Command
output_message
=
$(
kubectl
set
resources deployments
--limits
=
cpu
=
200m,memory
=
512Mi
--requests
=
cpu
=
100m,memory
=
512Mi
-l
run
=
web
--include-uninitialized
--all
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "resource requirements updated" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'resource requirements updated'
### Test kubectl set selector --include-uninitialized
# Create a service with initializer
kubectl create
--request-timeout
=
1
-f
hack/testdata/initializer-redis-master-service.yaml 2>&1
"
${
kube_flags
[@]
}
"
||
true
# Command
output_message
=
$(
kubectl
set
selector services
role
=
padawan
--all
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "selector updated" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'selector updated'
# Command
output_message
=
$(
kubectl
set
selector services
role
=
padawan
--all
--include-uninitialized
=
false
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The output should be empty
kube::test::if_empty_string
"
${
output_message
}
"
### Test kubectl set subject --include-uninitialized
# Create a create clusterrolebinding with initializer
kubectl create
--request-timeout
=
1
-f
hack/testdata/initializer-clusterrolebinding.yaml 2>&1
"
${
kube_flags
[@]
}
"
||
true
kube::test::get_object_assert clusterrolebinding/super-admin
"{{range.subjects}}{{.name}}:{{end}}"
'super-admin:'
# Command
output_message
=
$(
kubectl
set
subject clusterrolebinding
--user
=
foo
--all
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "subjects updated" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'subjects updated'
# Command
output_message
=
$(
kubectl
set
subject clusterrolebinding
--user
=
foo
--all
--include-uninitialized
=
false
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The output should be empty
kube::test::if_empty_string
"
${
output_message
}
"
# Command
output_message
=
$(
kubectl
set
subject clusterrolebinding
--user
=
foo
-l
clusterrolebinding
=
super 2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The output should be empty
kube::test::if_empty_string
"
${
output_message
}
"
# Command
output_message
=
$(
kubectl
set
subject clusterrolebinding
--user
=
foo
-l
clusterrolebinding
=
super
--include-uninitialized
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "subjects updated" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'subjects updated'
# Command
output_message
=
$(
kubectl
set
subject clusterrolebinding
--user
=
foo
-l
clusterrolebinding
=
super
--include-uninitialized
--all
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "subjects updated" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'subjects updated'
### Test kubectl set serviceaccount --include-uninitialized
# Command
output_message
=
$(
kubectl
set
serviceaccount deployment serviceaccount1
--all
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "serviceaccount updated" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'serviceaccount updated'
# Command
output_message
=
$(
kubectl
set
serviceaccount deployment serviceaccount1
--all
--include-uninitialized
=
false
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The output should be empty
kube::test::if_empty_string
"
${
output_message
}
"
### Test kubectl delete --include-uninitialized
kube::test::get_object_assert clusterrolebinding/super-admin
"{{range.subjects}}{{.name}}:{{end}}"
'super-admin:'
# Command
output_message
=
$(
kubectl delete clusterrolebinding
--all
--include-uninitialized
=
false
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "No resources found" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'No resources found'
# Command
output_message
=
$(
kubectl delete clusterrolebinding
--all
2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "deleted" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'deleted'
kube::test::get_object_assert clusterrolebinding/super-admin
"{{range.items}}{{
$id_field
}}:{{end}}"
''
### Test kubectl apply --include-uninitialized
# Pre-Condition: no POD exists
kube::test::get_object_assert pods
"{{range.items}}{{
$id_field
}}:{{end}}"
''
# apply pod a
kubectl apply
--prune
--request-timeout
=
20
--include-uninitialized
=
false
--all
-f
hack/testdata/prune/a.yaml
"
${
kube_flags
[@]
}
"
2>&1
# check right pod exists
kube::test::get_object_assert pods/a
"{{
${
id_field
}
}}"
'a'
# Post-condition: Other uninitialized resources should not be pruned
kube::test::get_object_assert deployments
"{{range.items}}{{
$id_field
}}:{{end}}"
'web'
kube::test::get_object_assert services/redis-master
"{{range.items}}{{
$id_field
}}:{{end}}"
'redis-master'
# cleanup
kubectl delete pod a
# apply pod a and prune uninitialized deployments web
kubectl apply
--prune
--request-timeout
=
20
--all
-f
hack/testdata/prune/a.yaml
"
${
kube_flags
[@]
}
"
2>&1
# check right pod exists
kube::test::get_object_assert pods/a
"{{
${
id_field
}
}}"
'a'
# Post-condition: Other uninitialized resources should not be pruned
kube::test::get_object_assert deployments/web
"{{range.items}}{{
$id_field
}}:{{end}}"
'web'
kube::test::get_object_assert services/redis-master
"{{range.items}}{{
$id_field
}}:{{end}}"
'redis-master'
# cleanup
kubectl delete pod a
# apply pod a and prune uninitialized deployments web
kubectl apply
--prune
--request-timeout
=
20
--include-uninitialized
--all
-f
hack/testdata/prune/a.yaml
"
${
kube_flags
[@]
}
"
2>&1
# check right pod exists
kube::test::get_object_assert pods/a
"{{
${
id_field
}
}}"
'a'
# Post-condition: Other uninitialized resources should not be pruned
kube::test::get_object_assert deployments/web
"{{range.items}}{{
$id_field
}}:{{end}}"
'web'
kube::test::get_object_assert services/redis-master
"{{range.items}}{{
$id_field
}}:{{end}}"
'redis-master'
# cleanup
kubectl delete pod a
kubectl delete
--request-timeout
=
1 deploy web
kubectl delete
--request-timeout
=
1 service redis-master
set
+o nounset
set
+o errexit
}
test/cmd/legacy-script.sh
View file @
89b0b0b8
...
...
@@ -39,7 +39,6 @@ source "${KUBE_ROOT}/test/cmd/diff.sh"
source
"
${
KUBE_ROOT
}
/test/cmd/discovery.sh"
source
"
${
KUBE_ROOT
}
/test/cmd/generic-resources.sh"
source
"
${
KUBE_ROOT
}
/test/cmd/get.sh"
source
"
${
KUBE_ROOT
}
/test/cmd/initializers.sh"
source
"
${
KUBE_ROOT
}
/test/cmd/kubeconfig.sh"
source
"
${
KUBE_ROOT
}
/test/cmd/node-management.sh"
source
"
${
KUBE_ROOT
}
/test/cmd/old-print.sh"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment