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
fe60be31
Commit
fe60be31
authored
Apr 08, 2015
by
nikhiljindal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moving v1beta1 kubectl examples to v1beta3
parent
ffffbb7e
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
39 additions
and
33 deletions
+39
-33
util.sh
cluster/libvirt-coreos/util.sh
+1
-1
util.sh
cluster/vagrant/util.sh
+1
-1
kubectl-get.md
docs/kubectl-get.md
+2
-2
kubectl-get.1
docs/man/man1/kubectl-get.1
+2
-2
e2e-status.sh
hack/e2e-internal/e2e-status.sh
+1
-1
services.sh
hack/e2e-suite/services.sh
+7
-7
get.go
pkg/kubectl/cmd/get.go
+2
-2
resource_printer_test.go
pkg/kubectl/resource_printer_test.go
+16
-10
util.go
test/e2e/util.go
+7
-7
No files found.
cluster/libvirt-coreos/util.sh
View file @
fe60be31
...
...
@@ -165,7 +165,7 @@ function wait-cluster-readiness {
local timeout
=
50
while
[[
$timeout
-ne
0
]]
;
do
nb_ready_minions
=
$(
"
${
kubectl
}
"
get
minions
-o
template
-t
"{{range.items}}{{range.status.conditions}}{{.kind}}{{end}}:{{end}}"
--api-version
=
v1beta1
2>/dev/null |
tr
':'
'\n'
|
grep
-c
Ready
||
true
)
nb_ready_minions
=
$(
"
${
kubectl
}
"
get
nodes
-o
template
-t
"{{range.items}}{{range.status.conditions}}{{.kind}}{{end}}:{{end}}"
--api-version
=
v1beta3
2>/dev/null |
tr
':'
'\n'
|
grep
-c
Ready
||
true
)
echo
"Nb ready minions:
$nb_ready_minions
/
$NUM_MINIONS
"
if
[[
"
$nb_ready_minions
"
-eq
"
$NUM_MINIONS
"
]]
;
then
return
0
...
...
cluster/vagrant/util.sh
View file @
fe60be31
...
...
@@ -165,7 +165,7 @@ function verify-cluster {
local
count
=
"0"
until
[[
"
$count
"
==
"1"
]]
;
do
local
minions
minions
=
$(
"
${
KUBE_ROOT
}
/cluster/kubectl.sh"
get
minions
-o
template
-t
'{{range.items}}{{.id}}:{{end}}'
--api-version
=
v1beta1
)
minions
=
$(
"
${
KUBE_ROOT
}
/cluster/kubectl.sh"
get
nodes
-o
template
-t
'{{range.items}}{{.metadata.name}}:{{end}}'
--api-version
=
v1beta3
)
count
=
$(
echo
$minions
|
grep
-c
"
${
MINION_IPS
[i]
}
"
)
||
{
printf
"."
sleep
2
...
...
docs/kubectl-get.md
View file @
fe60be31
...
...
@@ -29,8 +29,8 @@ $ kubectl get replicationController web
// List a single pod in JSON output format.
$ kubectl get -o json pod web-pod-13je7
// Return only the
status
value of the specified pod.
$ kubectl get -o template web-pod-13je7 --template={{.
currentState.status}} --api-version=v1beta1
// Return only the
phase
value of the specified pod.
$ kubectl get -o template web-pod-13je7 --template={{.
status.phase}} --api-version=v1beta3
// List all replication controllers and services together in ps output format.
$ kubectl get rc,services
...
...
docs/man/man1/kubectl-get.1
View file @
fe60be31
...
...
@@ -175,8 +175,8 @@ $ kubectl get replicationController web
// List a single pod in JSON output format.
$ kubectl get \-o json pod web\-pod\-13je7
// Return only the
status
value of the specified pod.
$ kubectl get \-o template web\-pod\-13je7 \-\-template=\{\{.
currentState.status\}\} \-\-api\-version=v1beta1
// Return only the
phase
value of the specified pod.
$ kubectl get \-o template web\-pod\-13je7 \-\-template=\{\{.
status.phase\}\} \-\-api\-version=v1beta3
// List all replication controllers and services together in ps output format.
$ kubectl get rc,services
...
...
hack/e2e-internal/e2e-status.sh
View file @
fe60be31
...
...
@@ -58,7 +58,7 @@ until [[ ${all_running} == 1 ]]; do
echo
"All pods never 'Running' in time."
>
&2
exit
1
fi
statuses
=(
$(${
KUBECTL
}
get pods
--template
=
'{{range.items}}{{.
currentState.status}} {{end}}'
--api-version
=
v1beta1
)
)
statuses
=(
$(${
KUBECTL
}
get pods
--template
=
'{{range.items}}{{.
status.phase}} {{end}}'
--api-version
=
v1beta3
)
)
# Ensure that we have enough pods.
echo
"Found
${#
statuses
[@]
}
pods with statuses:
${
statuses
[@]
}
"
>
&2
...
...
hack/e2e-suite/services.sh
View file @
fe60be31
...
...
@@ -151,8 +151,8 @@ function query_pods() {
local
i
for
i
in
$(
seq
1 10
)
;
do
pods_unsorted
=(
$(${
KUBECTL
}
get pods
-o
template
\
'--template={{range.items}}{{.
id
}} {{end}}'
\
'--api-version=v1beta
1
'
\
'--template={{range.items}}{{.
metadata.name
}} {{end}}'
\
'--api-version=v1beta
3
'
\
-l
name
=
"
$1
"
)
)
found
=
"
${#
pods_unsorted
[*]
}
"
if
[[
"
${
found
}
"
==
"
$2
"
]]
;
then
...
...
@@ -186,7 +186,7 @@ function wait_for_pods() {
echo
"Waiting for
${
pods_needed
}
pods to become 'running'"
pods_needed
=
"
$2
"
for
id
in
${
pods_sorted
}
;
do
status
=
$(${
KUBECTL
}
get pods
"
${
id
}
"
-o
template
--template
=
'{{.
currentState.status}}'
--api-version
=
v1beta1
)
status
=
$(${
KUBECTL
}
get pods
"
${
id
}
"
-o
template
--template
=
'{{.
status.phase}}'
--api-version
=
v1beta3
)
if
[[
"
${
status
}
"
==
"Running"
]]
;
then
pods_needed
=
$((
pods_needed-1
))
fi
...
...
@@ -312,9 +312,9 @@ svc1_pods=$(query_pods "${svc1_name}" "${svc1_count}")
svc2_pods
=
$(
query_pods
"
${
svc2_name
}
"
"
${
svc2_count
}
"
)
# Get the portal IPs.
svc1_ip
=
$(${
KUBECTL
}
get services
-o
template
'--template={{.
portalIP}}'
"
${
svc1_name
}
"
--api-version
=
v1beta1
)
svc1_ip
=
$(${
KUBECTL
}
get services
-o
template
'--template={{.
spec.portalIP}}'
"
${
svc1_name
}
"
--api-version
=
v1beta3
)
test
-n
"
${
svc1_ip
}
"
||
error
"Service1 IP is blank"
svc2_ip
=
$(${
KUBECTL
}
get services
-o
template
'--template={{.
portalIP}}'
"
${
svc2_name
}
"
--api-version
=
v1beta1
)
svc2_ip
=
$(${
KUBECTL
}
get services
-o
template
'--template={{.
spec.portalIP}}'
"
${
svc2_name
}
"
--api-version
=
v1beta3
)
test
-n
"
${
svc2_ip
}
"
||
error
"Service2 IP is blank"
if
[[
"
${
svc1_ip
}
"
==
"
${
svc2_ip
}
"
]]
;
then
error
"Portal IPs conflict:
${
svc1_ip
}
"
...
...
@@ -384,7 +384,7 @@ wait_for_pods "${svc3_name}" "${svc3_count}"
svc3_pods
=
$(
query_pods
"
${
svc3_name
}
"
"
${
svc3_count
}
"
)
# Get the portal IP.
svc3_ip
=
$(${
KUBECTL
}
get services
-o
template
'--template={{.
portalIP}}'
"
${
svc3_name
}
"
--api-version
=
v1beta1
)
svc3_ip
=
$(${
KUBECTL
}
get services
-o
template
'--template={{.
spec.portalIP}}'
"
${
svc3_name
}
"
--api-version
=
v1beta3
)
test
-n
"
${
svc3_ip
}
"
||
error
"Service3 IP is blank"
echo
"Verifying the portals from the host"
...
...
@@ -440,7 +440,7 @@ wait_for_pods "${svc4_name}" "${svc4_count}"
svc4_pods
=
$(
query_pods
"
${
svc4_name
}
"
"
${
svc4_count
}
"
)
# Get the portal IP.
svc4_ip
=
$(${
KUBECTL
}
get services
-o
template
'--template={{.
portalIP}}'
"
${
svc4_name
}
"
--api-version
=
v1beta1
)
svc4_ip
=
$(${
KUBECTL
}
get services
-o
template
'--template={{.
spec.portalIP}}'
"
${
svc4_name
}
"
--api-version
=
v1beta3
)
test
-n
"
${
svc4_ip
}
"
||
error
"Service4 IP is blank"
if
[[
"
${
svc4_ip
}
"
==
"
${
svc2_ip
}
"
||
"
${
svc4_ip
}
"
==
"
${
svc3_ip
}
"
]]
;
then
error
"Portal IPs conflict:
${
svc4_ip
}
"
...
...
pkg/kubectl/cmd/get.go
View file @
fe60be31
...
...
@@ -47,8 +47,8 @@ $ kubectl get replicationController web
// List a single pod in JSON output format.
$ kubectl get -o json pod web-pod-13je7
// Return only the
status
value of the specified pod.
$ kubectl get -o template web-pod-13je7 --template={{.
currentState.status}} --api-version=v1beta1
// Return only the
phase
value of the specified pod.
$ kubectl get -o template web-pod-13je7 --template={{.
status.phase}} --api-version=v1beta3
// List all replication controllers and services together in ps output format.
$ kubectl get rc,services
...
...
pkg/kubectl/resource_printer_test.go
View file @
fe60be31
...
...
@@ -367,7 +367,7 @@ func TestTemplateStrings(t *testing.T) {
},
"false"
,
},
"
one
Valid"
:
{
"
bar
Valid"
:
{
api
.
Pod
{
Status
:
api
.
PodStatus
{
ContainerStatuses
:
[]
api
.
ContainerStatus
{
...
...
@@ -413,26 +413,28 @@ func TestTemplateStrings(t *testing.T) {
"true"
,
},
}
// The point of this test is to verify that the below template works. If you change this
// template, you need to update hack/e2e-suite/update.sh.
tmpl
:=
`{{and (exists . "currentState" "info" "foo" "state" "running") (exists . "currentState" "info" "bar" "state" "running")}}`
useThisToDebug
:=
`
tmpl
:=
``
if
api
.
PreV1Beta3
(
testapi
.
Version
())
{
tmpl
=
`{{exists . "currentState" "info" "foo" "state" "running"}}`
useThisToDebug
:=
`
a: {{exists . "currentState"}}
b: {{exists . "currentState" "info"}}
c: {{exists . "currentState" "info" "foo"}}
d: {{exists . "currentState" "info" "foo" "state"}}
e: {{exists . "currentState" "info" "foo" "state" "running"}}
f: {{exists . "currentState" "info" "foo" "state" "running" "startedAt"}}`
_
=
useThisToDebug
// don't complain about unused var
_
=
useThisToDebug
// don't complain about unused var
}
else
{
tmpl
=
`{{if (exists . "status" "containerStatuses")}}{{range .status.containerStatuses}}{{if (and (eq .name "foo") (exists . "state" "running"))}}true{{end}}{{end}}{{end}}`
}
p
,
err
:=
NewTemplatePrinter
([]
byte
(
tmpl
))
if
err
!=
nil
{
t
.
Fatalf
(
"tmpl fail: %v"
,
err
)
}
printer
:=
NewVersionedPrinter
(
p
,
api
.
Scheme
,
"v1beta1"
)
printer
:=
NewVersionedPrinter
(
p
,
api
.
Scheme
,
testapi
.
Version
()
)
for
name
,
item
:=
range
table
{
buffer
:=
&
bytes
.
Buffer
{}
...
...
@@ -441,8 +443,12 @@ f: {{exists . "currentState" "info" "foo" "state" "running" "startedAt"}}`
t
.
Errorf
(
"%v: unexpected err: %v"
,
name
,
err
)
continue
}
if
e
,
a
:=
item
.
expect
,
buffer
.
String
();
e
!=
a
{
t
.
Errorf
(
"%v: expected %v, got %v"
,
name
,
e
,
a
)
actual
:=
buffer
.
String
()
if
len
(
actual
)
==
0
{
actual
=
"false"
}
if
e
:=
item
.
expect
;
e
!=
actual
{
t
.
Errorf
(
"%v: expected %v, got %v"
,
name
,
e
,
actual
)
}
}
}
...
...
test/e2e/util.go
View file @
fe60be31
...
...
@@ -216,7 +216,7 @@ type validatorFn func(c *client.Client, podID string) error
// "testname": which gets bubbled up to the logging/failure messages if errors happen.
// "validator" function: This function is given a podID and a client, and it can do some specific validations that way.
func
validateController
(
c
*
client
.
Client
,
containerImage
string
,
replicas
int
,
containername
string
,
testname
string
,
validator
validatorFn
)
{
getPodsTemplate
:=
"--template={{range.items}}{{.
id
}} {{end}}"
getPodsTemplate
:=
"--template={{range.items}}{{.
metadata.name
}} {{end}}"
// NB: kubectl adds the "exists" function to the standard template functions.
// This lets us check to see if the "running" entry exists for each of the containers
// we care about. Exists will never return an error and it's safe to check a chain of
...
...
@@ -225,13 +225,13 @@ func validateController(c *client.Client, containerImage string, replicas int, c
// helpful.
// This template is unit-tested in kubectl, so if you change it, update the unit test.
// You can read about the syntax here: http://golang.org/pkg/text/template/.
getContainerStateTemplate
:=
fmt
.
Sprintf
(
`--template={{
and (exists . "currentState" "info" "%s" "state" "running")
}}`
,
containername
)
getContainerStateTemplate
:=
fmt
.
Sprintf
(
`--template={{
if (exists . "status" "containerStatuses")}}{{range .status.containerStatuses}}{{if (and (eq .name "%s") (exists . "state" "running"))}}true{{end}}{{end}}{{end
}}`
,
containername
)
getImageTemplate
:=
fmt
.
Sprintf
(
`--template={{
(index .currentState.info "%s").image
}}`
,
containername
)
getImageTemplate
:=
fmt
.
Sprintf
(
`--template={{
if (exists . "status" "containerStatuses")}}{{range .status.containerStatuses}}{{if eq .name "%s"}}{{.image}}{{end}}{{end}}{{end
}}`
,
containername
)
By
(
fmt
.
Sprintf
(
"waiting for all containers in %s pods to come up."
,
testname
))
//testname should be selector
for
start
:=
time
.
Now
();
time
.
Since
(
start
)
<
podStartTimeout
;
time
.
Sleep
(
5
*
time
.
Second
)
{
getPodsOutput
:=
runKubectl
(
"get"
,
"pods"
,
"-o"
,
"template"
,
getPodsTemplate
,
"--api-version=v1beta
1
"
,
"-l"
,
testname
)
getPodsOutput
:=
runKubectl
(
"get"
,
"pods"
,
"-o"
,
"template"
,
getPodsTemplate
,
"--api-version=v1beta
3
"
,
"-l"
,
testname
)
pods
:=
strings
.
Fields
(
getPodsOutput
)
if
numPods
:=
len
(
pods
);
numPods
!=
replicas
{
By
(
fmt
.
Sprintf
(
"Replicas for %s: expected=%d actual=%d"
,
testname
,
replicas
,
numPods
))
...
...
@@ -239,13 +239,13 @@ func validateController(c *client.Client, containerImage string, replicas int, c
}
var
runningPods
[]
string
for
_
,
podID
:=
range
pods
{
running
:=
runKubectl
(
"get"
,
"pods"
,
podID
,
"-o"
,
"template"
,
getContainerStateTemplate
,
"--api-version=v1beta
1
"
)
if
running
==
"fals
e"
{
running
:=
runKubectl
(
"get"
,
"pods"
,
podID
,
"-o"
,
"template"
,
getContainerStateTemplate
,
"--api-version=v1beta
3
"
)
if
running
!=
"tru
e"
{
Logf
(
"%s is created but not running"
,
podID
)
continue
}
currentImage
:=
runKubectl
(
"get"
,
"pods"
,
podID
,
"-o"
,
"template"
,
getImageTemplate
,
"--api-version=v1beta
1
"
)
currentImage
:=
runKubectl
(
"get"
,
"pods"
,
podID
,
"-o"
,
"template"
,
getImageTemplate
,
"--api-version=v1beta
3
"
)
if
currentImage
!=
containerImage
{
Logf
(
"%s is created but running wrong image; expected: %s, actual: %s"
,
podID
,
containerImage
,
currentImage
)
continue
...
...
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