Merge pull request #10604 from nikhiljindal/v1

Updating scripts to use v1 instead of v1beta3
pull/6/head
Zach Loafman 2015-07-01 15:54:17 -07:00
commit e5670c104d
26 changed files with 53 additions and 79 deletions

View File

@ -216,7 +216,7 @@ def register_machine(apiserver, retry=False):
response, result = registration_request.register(parsed.hostname,
parsed.port,
'/api/v1beta3/nodes')
'/api/v1/nodes')
print(response)

View File

@ -37,12 +37,12 @@ class TestRegistrator():
@patch('json.loads')
@patch('httplib.HTTPConnection')
def test_register(self, httplibmock, jsonmock):
result = self.r.register('foo', 80, '/v1beta3/test')
result = self.r.register('foo', 80, '/v1/test')
httplibmock.assert_called_with('foo', 80)
requestmock = httplibmock().request
requestmock.assert_called_with(
"POST", "/v1beta3/test",
"POST", "/v1/test",
json.dumps(self.r.data),
{"Content-type": "application/json",
"Accept": "application/json"})
@ -50,7 +50,7 @@ class TestRegistrator():
def test_command_succeeded(self):
response = MagicMock()
result = json.loads('{"status": "Failure", "kind": "Status", "code": 409, "apiVersion": "v1beta2", "reason": "AlreadyExists", "details": {"kind": "minion", "id": "10.200.147.200"}, "message": "minion \\"10.200.147.200\\" already exists", "creationTimestamp": null}')
result = json.loads('{"status": "Failure", "kind": "Status", "code": 409, "apiVersion": "v1", "reason": "AlreadyExists", "details": {"kind": "node", "name": "10.200.147.200"}, "message": "node \\"10.200.147.200\\" already exists", "creationTimestamp": null}')
response.status = 200
self.r.command_succeeded(response, result)
response.status = 500

View File

@ -1,4 +1,4 @@
apiVersion: v1beta3
apiVersion: v1
kind: ReplicationController
metadata:
labels:

View File

@ -1,4 +1,4 @@
apiVersion: v1beta3
apiVersion: v1
kind: Service
metadata:
labels:

View File

@ -183,7 +183,7 @@ function wait-cluster-readiness {
local timeout=120
while [[ $timeout -ne 0 ]]; do
nb_ready_minions=$("${kubectl}" get nodes -o template -t "{{range.items}}{{range.status.conditions}}{{.type}}{{end}}:{{end}}" --api-version=v1beta3 2>/dev/null | tr ':' '\n' | grep -c Ready || true)
nb_ready_minions=$("${kubectl}" get nodes -o template -t "{{range.items}}{{range.status.conditions}}{{.type}}{{end}}:{{end}}" --api-version=v1 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

View File

@ -61,8 +61,8 @@ ENABLE_CLUSTER_LOGGING=false
ELASTICSEARCH_LOGGING_REPLICAS=1
# Optional: Cluster monitoring to setup as part of the cluster bring up:
# none - No cluster monitoring setup
# influxdb - Heapster, InfluxDB, and Grafana
# none - No cluster monitoring setup
# influxdb - Heapster, InfluxDB, and Grafana
# google - Heapster, Google Cloud Monitoring, and Google Cloud Logging
ENABLE_CLUSTER_MONITORING="${KUBE_ENABLE_CLUSTER_MONITORING:-influxdb}"
@ -81,4 +81,4 @@ DNS_REPLICAS=1
# Optional: Enable setting flags for kube-apiserver to turn on behavior in active-dev
#RUNTIME_CONFIG=""
RUNTIME_CONFIG="api/v1beta3"
RUNTIME_CONFIG="api/v1"

View File

@ -228,7 +228,7 @@ function verify-cluster {
local count="0"
until [[ "$count" == "1" ]]; do
local minions
minions=$("${KUBE_ROOT}/cluster/kubectl.sh" get nodes -o template -t '{{range.items}}{{.metadata.name}}:{{end}}' --api-version=v1beta3)
minions=$("${KUBE_ROOT}/cluster/kubectl.sh" get nodes -o template -t '{{range.items}}{{.metadata.name}}:{{end}}' --api-version=v1)
count=$(echo $minions | grep -c "${MINION_IPS[i]}") || {
printf "."
sleep 2

View File

@ -185,7 +185,7 @@ function run-until-success() {
# $1 object type
function get-addons-from-server() {
local -r obj_type=$1
"${KUBECTL}" get "${obj_type}" -o template -t "{{range.items}}{{.metadata.name}} {{end}}" --api-version=v1beta3 -l kubernetes.io/cluster-service=true
"${KUBECTL}" get "${obj_type}" -o template -t "{{range.items}}{{.metadata.name}} {{end}}" --api-version=v1 -l kubernetes.io/cluster-service=true
}
# returns the characters after the last separator (including)

View File

@ -76,7 +76,7 @@ EOF
local -r kubeconfig_base64=$(echo "${kubeconfig}" | base64 -w0)
read -r -d '' secretyaml <<EOF
apiVersion: v1beta3
apiVersion: v1
data:
kubeconfig: ${kubeconfig_base64}
kind: Secret

View File

@ -1,6 +1,6 @@
{
"kind": "ReplicationController",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "nettest-controller",
"labels": {

View File

@ -1,6 +1,6 @@
{
"kind": "Service",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "nettest",
"labels": {

View File

@ -1,4 +1,4 @@
apiVersion: v1beta3
apiVersion: v1
kind: Pod
metadata:
labels:

View File

@ -1,9 +1,9 @@
apiVersion: v1beta3
apiVersion: v1
kind: Service
metadata:
name: blog-service
spec:
createExternalLoadBalancer: true
type: "LoadBalancer"
ports:
- port: 80
selector:

View File

@ -1,4 +1,4 @@
apiVersion: v1beta3
apiVersion: v1
kind: Pod
metadata:
labels:

View File

@ -1,4 +1,4 @@
apiVersion: v1beta3
apiVersion: v1
kind: Pod
metadata:
labels:

View File

@ -43,7 +43,7 @@ Now, you can access the service `wget 10.0.1.89:9090`, and build graphs.
## How it works
This is a v1beta3 based, containerized prometheus ReplicationController, which scrapes endpoints which are readable on the KUBERNETES service (the internal kubernetes service running in the default namespace, which is visible to all pods).
This is a v1 api based, containerized prometheus ReplicationController, which scrapes endpoints which are readable on the KUBERNETES service (the internal kubernetes service running in the default namespace, which is visible to all pods).
1. Use kubectl to handle auth & proxy the kubernetes API locally, emulating the old KUBERNETES_RO service.

View File

@ -1,5 +1,5 @@
{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "ReplicationController",
"metadata": {
"labels": {

View File

@ -1,6 +1,6 @@
{
"kind":"Service",
"apiVersion":"v1beta3",
"apiVersion":"v1",
"metadata":{
"name":"prometheus",
"labels":{
@ -8,7 +8,7 @@
}
},
"spec":{
"publicIPs":["10.0.1.89"],
"type": "NodePort",
"ports": [
{
"port":9090,

View File

@ -33,7 +33,7 @@ runTests() {
kube::log::status "Running benchmarks"
KUBE_GOFLAGS="-tags 'benchmark no-docker' -bench . -benchtime 1s -cpu 4" \
KUBE_RACE="-race" \
KUBE_TEST_API_VERSIONS="v1beta3" \
KUBE_TEST_API_VERSIONS="v1" \
KUBE_TIMEOUT="-timeout 10m" \
KUBE_TEST_ETCD_PREFIXES="registry"\
ETCD_CUSTOM_PREFIX="None" \

View File

@ -1,9 +1,9 @@
{
"kind": "Node",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "e2e-test-wojtekt-minion-etd6",
"selfLink": "/api/v1beta3/nodes/e2e-test-wojtekt-minion-etd6",
"selfLink": "/api/v1/nodes/e2e-test-wojtekt-minion-etd6",
"uid": "a7e89222-e8e5-11e4-8fde-42010af09327",
"resourceVersion": "379",
"creationTimestamp": "2015-04-22T11:49:39Z"

View File

@ -1,10 +1,10 @@
{
"kind": "Pod",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "etcd-server-e2e-test-wojtekt-master",
"namespace": "default",
"selfLink": "/api/v1beta3/namespaces/default/pods/etcd-server-e2e-test-wojtekt-master",
"selfLink": "/api/v1/namespaces/default/pods/etcd-server-e2e-test-wojtekt-master",
"uid": "a671734a-e8e5-11e4-8fde-42010af09327",
"resourceVersion": "22",
"creationTimestamp": "2015-04-22T11:49:36Z",
@ -71,12 +71,12 @@
],
"restartPolicy": "Always",
"dnsPolicy": "ClusterFirst",
"host": "e2e-test-wojtekt-master",
"nodeName": "e2e-test-wojtekt-master",
"hostNetwork": true
},
"status": {
"phase": "Running",
"Condition": [
"conditions": [
{
"type": "Ready",
"status": "True"

View File

@ -1,10 +1,10 @@
{
"kind": "ReplicationController",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "elasticsearch-logging-controller",
"namespace": "default",
"selfLink": "/api/v1beta3/namespaces/default/replicationcontrollers/elasticsearch-logging-controller",
"selfLink": "/api/v1/namespaces/default/replicationcontrollers/elasticsearch-logging-controller",
"uid": "aa76f162-e8e5-11e4-8fde-42010af09327",
"resourceVersion": "98",
"creationTimestamp": "2015-04-22T11:49:43Z",

View File

@ -17,20 +17,22 @@ limitations under the License.
package runtime_test
import (
"fmt"
"testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
)
func TestDecodeUnstructured(t *testing.T) {
version := testapi.Version()
rawJson := fmt.Sprintf(`{"kind":"Pod","apiVersion":"%s","metadata":{"name":"test"}}`, version)
pl := &api.List{
Items: []runtime.Object{
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "1"}},
&runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "Pod", APIVersion: "v1beta3"}, RawJSON: []byte(`{"kind":"Pod","apiVersion":"v1beta3","metadata":{"name":"test"}}`)},
&runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "", APIVersion: "v1beta3"}, RawJSON: []byte(`{"kind":"Pod","apiVersion":"v1beta3","metadata":{"name":"test"}}`)},
&runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "Pod", APIVersion: "v1"}, RawJSON: []byte(`{"kind":"Pod","apiVersion":"v1","metadata":{"name":"test"}}`)},
&runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "", APIVersion: "v1"}, RawJSON: []byte(`{"kind":"Pod","apiVersion":"v1","metadata":{"name":"test"}}`)},
&runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "Pod", APIVersion: version}, RawJSON: []byte(rawJson)},
&runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "", APIVersion: version}, RawJSON: []byte(rawJson)},
&runtime.Unstructured{TypeMeta: runtime.TypeMeta{Kind: "Foo", APIVersion: "Bar"}, Object: map[string]interface{}{"test": "value"}},
},
}

View File

@ -54,11 +54,7 @@ import (
var nodeResourceName string
func init() {
if api.PreV1Beta3(testapi.Version()) {
nodeResourceName = "minions"
} else {
nodeResourceName = "nodes"
}
nodeResourceName = "nodes"
}
const (
@ -90,7 +86,7 @@ func timeoutPath(resource, namespace, name string) string {
var aPod string = `
{
"kind": "Pod",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "a",
"creationTimestamp": null%s
@ -108,7 +104,7 @@ var aPod string = `
var aRC string = `
{
"kind": "ReplicationController",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "a",
"labels": {
@ -141,7 +137,7 @@ var aRC string = `
var aService string = `
{
"kind": "Service",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "a",
"labels": {
@ -158,14 +154,14 @@ var aService string = `
"selector": {
"name": "a"
},
"portalIP": "10.0.0.100"
"clusterIP": "10.0.0.100"
}
}
`
var aNode string = `
{
"kind": "Node",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "a"%s
},
@ -177,7 +173,7 @@ var aNode string = `
var aEvent string = `
{
"kind": "Event",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "a"%s
},
@ -185,7 +181,7 @@ var aEvent string = `
"kind": "Node",
"namespace": "default",
"name": "a",
"apiVersion": "v1beta3"
"apiVersion": "v1"
}
}
`
@ -193,7 +189,7 @@ var aEvent string = `
var aBinding string = `
{
"kind": "Binding",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "a"%s
},
@ -206,7 +202,7 @@ var aBinding string = `
var aEndpoints string = `
{
"kind": "Endpoints",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "a"%s
},
@ -214,7 +210,7 @@ var aEndpoints string = `
{
"addresses": [
{
"IP": "10.10.1.1"
"ip": "10.10.1.1"
}
],
"ports": [
@ -231,7 +227,7 @@ var aEndpoints string = `
var deleteNow string = `
{
"kind": "DeleteOptions",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"gracePeriodSeconds": null%s
}
`
@ -462,17 +458,6 @@ func parseResourceVersion(response []byte) (string, float64, error) {
if err != nil {
return "", 0, fmt.Errorf("unexpected error unmarshaling resultBody: %v", err)
}
apiVersion, ok := resultBodyMap["apiVersion"].(string)
if !ok {
return "", 0, fmt.Errorf("unexpected error, apiVersion not found in JSON response: %v", string(response))
}
if api.PreV1Beta3(apiVersion) {
return parsePreV1Beta3ResourceVersion(resultBodyMap, response)
}
return parseV1Beta3ResourceVersion(resultBodyMap, response)
}
func parseV1Beta3ResourceVersion(resultBodyMap map[string]interface{}, response []byte) (string, float64, error) {
metadata, ok := resultBodyMap["metadata"].(map[string]interface{})
if !ok {
return "", 0, fmt.Errorf("unexpected error, metadata not found in JSON response: %v", string(response))
@ -492,19 +477,6 @@ func parseV1Beta3ResourceVersion(resultBodyMap map[string]interface{}, response
return id, resourceVersion, nil
}
func parsePreV1Beta3ResourceVersion(resultBodyMap map[string]interface{}, response []byte) (string, float64, error) {
id, ok := resultBodyMap["id"].(string)
if !ok {
return "", 0, fmt.Errorf("unexpected error, id not found in JSON response: %v", string(response))
}
resourceVersion, ok := resultBodyMap["resourceVersion"].(float64)
if !ok {
return "", 0, fmt.Errorf("unexpected error, resourceVersion not found in JSON response: %v", string(response))
}
return id, resourceVersion, nil
}
func getPreviousResourceVersionKey(url, id string) string {
baseUrl := strings.Split(url, "?")[0]
key := baseUrl

View File

@ -1,6 +1,6 @@
{
"kind": "ReplicationController",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "test-controller",
"namespace": "test",

View File

@ -97,7 +97,7 @@ func NewMasterComponents(c *Config) *MasterComponents {
if c.DeleteEtcdKeys {
DeleteAllEtcdKeys()
}
restClient := client.NewOrDie(&client.Config{Host: s.URL, Version: "v1beta3", QPS: c.QPS, Burst: c.Burst})
restClient := client.NewOrDie(&client.Config{Host: s.URL, Version: testapi.Version(), QPS: c.QPS, Burst: c.Burst})
rcStopCh := make(chan struct{})
controllerManager := controller.NewReplicationManager(restClient, c.Burst)