Commit 2e9e46dd authored by nikhiljindal's avatar nikhiljindal

Updating scripts to use v1 instead of v1beta3

parent 09df440b
...@@ -216,7 +216,7 @@ def register_machine(apiserver, retry=False): ...@@ -216,7 +216,7 @@ def register_machine(apiserver, retry=False):
response, result = registration_request.register(parsed.hostname, response, result = registration_request.register(parsed.hostname,
parsed.port, parsed.port,
'/api/v1beta3/nodes') '/api/v1/nodes')
print(response) print(response)
......
...@@ -37,12 +37,12 @@ class TestRegistrator(): ...@@ -37,12 +37,12 @@ class TestRegistrator():
@patch('json.loads') @patch('json.loads')
@patch('httplib.HTTPConnection') @patch('httplib.HTTPConnection')
def test_register(self, httplibmock, jsonmock): 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) httplibmock.assert_called_with('foo', 80)
requestmock = httplibmock().request requestmock = httplibmock().request
requestmock.assert_called_with( requestmock.assert_called_with(
"POST", "/v1beta3/test", "POST", "/v1/test",
json.dumps(self.r.data), json.dumps(self.r.data),
{"Content-type": "application/json", {"Content-type": "application/json",
"Accept": "application/json"}) "Accept": "application/json"})
...@@ -50,7 +50,7 @@ class TestRegistrator(): ...@@ -50,7 +50,7 @@ class TestRegistrator():
def test_command_succeeded(self): def test_command_succeeded(self):
response = MagicMock() 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 response.status = 200
self.r.command_succeeded(response, result) self.r.command_succeeded(response, result)
response.status = 500 response.status = 500
......
apiVersion: v1beta3 apiVersion: v1
kind: ReplicationController kind: ReplicationController
metadata: metadata:
labels: labels:
......
apiVersion: v1beta3 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
labels: labels:
......
...@@ -183,7 +183,7 @@ function wait-cluster-readiness { ...@@ -183,7 +183,7 @@ function wait-cluster-readiness {
local timeout=120 local timeout=120
while [[ $timeout -ne 0 ]]; do 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" echo "Nb ready minions: $nb_ready_minions / $NUM_MINIONS"
if [[ "$nb_ready_minions" -eq "$NUM_MINIONS" ]]; then if [[ "$nb_ready_minions" -eq "$NUM_MINIONS" ]]; then
return 0 return 0
......
...@@ -61,8 +61,8 @@ ENABLE_CLUSTER_LOGGING=false ...@@ -61,8 +61,8 @@ ENABLE_CLUSTER_LOGGING=false
ELASTICSEARCH_LOGGING_REPLICAS=1 ELASTICSEARCH_LOGGING_REPLICAS=1
# Optional: Cluster monitoring to setup as part of the cluster bring up: # Optional: Cluster monitoring to setup as part of the cluster bring up:
# none - No cluster monitoring setup # none - No cluster monitoring setup
# influxdb - Heapster, InfluxDB, and Grafana # influxdb - Heapster, InfluxDB, and Grafana
# google - Heapster, Google Cloud Monitoring, and Google Cloud Logging # google - Heapster, Google Cloud Monitoring, and Google Cloud Logging
ENABLE_CLUSTER_MONITORING="${KUBE_ENABLE_CLUSTER_MONITORING:-influxdb}" ENABLE_CLUSTER_MONITORING="${KUBE_ENABLE_CLUSTER_MONITORING:-influxdb}"
...@@ -81,4 +81,4 @@ DNS_REPLICAS=1 ...@@ -81,4 +81,4 @@ DNS_REPLICAS=1
# Optional: Enable setting flags for kube-apiserver to turn on behavior in active-dev # Optional: Enable setting flags for kube-apiserver to turn on behavior in active-dev
#RUNTIME_CONFIG="" #RUNTIME_CONFIG=""
RUNTIME_CONFIG="api/v1beta3" RUNTIME_CONFIG="api/v1"
...@@ -228,7 +228,7 @@ function verify-cluster { ...@@ -228,7 +228,7 @@ function verify-cluster {
local count="0" local count="0"
until [[ "$count" == "1" ]]; do until [[ "$count" == "1" ]]; do
local minions 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]}") || { count=$(echo $minions | grep -c "${MINION_IPS[i]}") || {
printf "." printf "."
sleep 2 sleep 2
......
...@@ -185,7 +185,7 @@ function run-until-success() { ...@@ -185,7 +185,7 @@ function run-until-success() {
# $1 object type # $1 object type
function get-addons-from-server() { function get-addons-from-server() {
local -r obj_type=$1 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) # returns the characters after the last separator (including)
......
...@@ -76,7 +76,7 @@ EOF ...@@ -76,7 +76,7 @@ EOF
local -r kubeconfig_base64=$(echo "${kubeconfig}" | base64 -w0) local -r kubeconfig_base64=$(echo "${kubeconfig}" | base64 -w0)
read -r -d '' secretyaml <<EOF read -r -d '' secretyaml <<EOF
apiVersion: v1beta3 apiVersion: v1
data: data:
kubeconfig: ${kubeconfig_base64} kubeconfig: ${kubeconfig_base64}
kind: Secret kind: Secret
......
{ {
"kind": "ReplicationController", "kind": "ReplicationController",
"apiVersion": "v1beta3", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "nettest-controller", "name": "nettest-controller",
"labels": { "labels": {
......
{ {
"kind": "Service", "kind": "Service",
"apiVersion": "v1beta3", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "nettest", "name": "nettest",
"labels": { "labels": {
......
apiVersion: v1beta3 apiVersion: v1
kind: Pod kind: Pod
metadata: metadata:
labels: labels:
......
apiVersion: v1beta3 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: blog-service name: blog-service
spec: spec:
createExternalLoadBalancer: true type: "LoadBalancer"
ports: ports:
- port: 80 - port: 80
selector: selector:
......
apiVersion: v1beta3 apiVersion: v1
kind: Pod kind: Pod
metadata: metadata:
labels: labels:
......
apiVersion: v1beta3 apiVersion: v1
kind: Pod kind: Pod
metadata: metadata:
labels: labels:
......
...@@ -43,7 +43,7 @@ Now, you can access the service `wget 10.0.1.89:9090`, and build graphs. ...@@ -43,7 +43,7 @@ Now, you can access the service `wget 10.0.1.89:9090`, and build graphs.
## How it works ## 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. 1. Use kubectl to handle auth & proxy the kubernetes API locally, emulating the old KUBERNETES_RO service.
......
{ {
"apiVersion": "v1beta3", "apiVersion": "v1",
"kind": "ReplicationController", "kind": "ReplicationController",
"metadata": { "metadata": {
"labels": { "labels": {
......
{ {
"kind":"Service", "kind":"Service",
"apiVersion":"v1beta3", "apiVersion":"v1",
"metadata":{ "metadata":{
"name":"prometheus", "name":"prometheus",
"labels":{ "labels":{
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
} }
}, },
"spec":{ "spec":{
"publicIPs":["10.0.1.89"], "type": "NodePort",
"ports": [ "ports": [
{ {
"port":9090, "port":9090,
......
...@@ -33,7 +33,7 @@ runTests() { ...@@ -33,7 +33,7 @@ runTests() {
kube::log::status "Running benchmarks" kube::log::status "Running benchmarks"
KUBE_GOFLAGS="-tags 'benchmark no-docker' -bench . -benchtime 1s -cpu 4" \ KUBE_GOFLAGS="-tags 'benchmark no-docker' -bench . -benchtime 1s -cpu 4" \
KUBE_RACE="-race" \ KUBE_RACE="-race" \
KUBE_TEST_API_VERSIONS="v1beta3" \ KUBE_TEST_API_VERSIONS="v1" \
KUBE_TIMEOUT="-timeout 10m" \ KUBE_TIMEOUT="-timeout 10m" \
KUBE_TEST_ETCD_PREFIXES="registry"\ KUBE_TEST_ETCD_PREFIXES="registry"\
ETCD_CUSTOM_PREFIX="None" \ ETCD_CUSTOM_PREFIX="None" \
......
{ {
"kind": "Node", "kind": "Node",
"apiVersion": "v1beta3", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "e2e-test-wojtekt-minion-etd6", "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", "uid": "a7e89222-e8e5-11e4-8fde-42010af09327",
"resourceVersion": "379", "resourceVersion": "379",
"creationTimestamp": "2015-04-22T11:49:39Z" "creationTimestamp": "2015-04-22T11:49:39Z"
......
{ {
"kind": "Pod", "kind": "Pod",
"apiVersion": "v1beta3", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "etcd-server-e2e-test-wojtekt-master", "name": "etcd-server-e2e-test-wojtekt-master",
"namespace": "default", "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", "uid": "a671734a-e8e5-11e4-8fde-42010af09327",
"resourceVersion": "22", "resourceVersion": "22",
"creationTimestamp": "2015-04-22T11:49:36Z", "creationTimestamp": "2015-04-22T11:49:36Z",
...@@ -71,12 +71,12 @@ ...@@ -71,12 +71,12 @@
], ],
"restartPolicy": "Always", "restartPolicy": "Always",
"dnsPolicy": "ClusterFirst", "dnsPolicy": "ClusterFirst",
"host": "e2e-test-wojtekt-master", "nodeName": "e2e-test-wojtekt-master",
"hostNetwork": true "hostNetwork": true
}, },
"status": { "status": {
"phase": "Running", "phase": "Running",
"Condition": [ "conditions": [
{ {
"type": "Ready", "type": "Ready",
"status": "True" "status": "True"
......
{ {
"kind": "ReplicationController", "kind": "ReplicationController",
"apiVersion": "v1beta3", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "elasticsearch-logging-controller", "name": "elasticsearch-logging-controller",
"namespace": "default", "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", "uid": "aa76f162-e8e5-11e4-8fde-42010af09327",
"resourceVersion": "98", "resourceVersion": "98",
"creationTimestamp": "2015-04-22T11:49:43Z", "creationTimestamp": "2015-04-22T11:49:43Z",
......
...@@ -17,20 +17,22 @@ limitations under the License. ...@@ -17,20 +17,22 @@ limitations under the License.
package runtime_test package runtime_test
import ( import (
"fmt"
"testing" "testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
) )
func TestDecodeUnstructured(t *testing.T) { func TestDecodeUnstructured(t *testing.T) {
version := testapi.Version()
rawJson := fmt.Sprintf(`{"kind":"Pod","apiVersion":"%s","metadata":{"name":"test"}}`, version)
pl := &api.List{ pl := &api.List{
Items: []runtime.Object{ Items: []runtime.Object{
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "1"}}, &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: "Pod", APIVersion: version}, RawJSON: []byte(rawJson)},
&runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "", APIVersion: "v1beta3"}, RawJSON: []byte(`{"kind":"Pod","apiVersion":"v1beta3","metadata":{"name":"test"}}`)}, &runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "", APIVersion: version}, RawJSON: []byte(rawJson)},
&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.Unstructured{TypeMeta: runtime.TypeMeta{Kind: "Foo", APIVersion: "Bar"}, Object: map[string]interface{}{"test": "value"}}, &runtime.Unstructured{TypeMeta: runtime.TypeMeta{Kind: "Foo", APIVersion: "Bar"}, Object: map[string]interface{}{"test": "value"}},
}, },
} }
......
...@@ -54,11 +54,7 @@ import ( ...@@ -54,11 +54,7 @@ import (
var nodeResourceName string var nodeResourceName string
func init() { func init() {
if api.PreV1Beta3(testapi.Version()) { nodeResourceName = "nodes"
nodeResourceName = "minions"
} else {
nodeResourceName = "nodes"
}
} }
const ( const (
...@@ -90,7 +86,7 @@ func timeoutPath(resource, namespace, name string) string { ...@@ -90,7 +86,7 @@ func timeoutPath(resource, namespace, name string) string {
var aPod string = ` var aPod string = `
{ {
"kind": "Pod", "kind": "Pod",
"apiVersion": "v1beta3", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "a", "name": "a",
"creationTimestamp": null%s "creationTimestamp": null%s
...@@ -108,7 +104,7 @@ var aPod string = ` ...@@ -108,7 +104,7 @@ var aPod string = `
var aRC string = ` var aRC string = `
{ {
"kind": "ReplicationController", "kind": "ReplicationController",
"apiVersion": "v1beta3", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "a", "name": "a",
"labels": { "labels": {
...@@ -141,7 +137,7 @@ var aRC string = ` ...@@ -141,7 +137,7 @@ var aRC string = `
var aService string = ` var aService string = `
{ {
"kind": "Service", "kind": "Service",
"apiVersion": "v1beta3", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "a", "name": "a",
"labels": { "labels": {
...@@ -158,14 +154,14 @@ var aService string = ` ...@@ -158,14 +154,14 @@ var aService string = `
"selector": { "selector": {
"name": "a" "name": "a"
}, },
"portalIP": "10.0.0.100" "clusterIP": "10.0.0.100"
} }
} }
` `
var aNode string = ` var aNode string = `
{ {
"kind": "Node", "kind": "Node",
"apiVersion": "v1beta3", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "a"%s "name": "a"%s
}, },
...@@ -177,7 +173,7 @@ var aNode string = ` ...@@ -177,7 +173,7 @@ var aNode string = `
var aEvent string = ` var aEvent string = `
{ {
"kind": "Event", "kind": "Event",
"apiVersion": "v1beta3", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "a"%s "name": "a"%s
}, },
...@@ -185,7 +181,7 @@ var aEvent string = ` ...@@ -185,7 +181,7 @@ var aEvent string = `
"kind": "Node", "kind": "Node",
"namespace": "default", "namespace": "default",
"name": "a", "name": "a",
"apiVersion": "v1beta3" "apiVersion": "v1"
} }
} }
` `
...@@ -193,7 +189,7 @@ var aEvent string = ` ...@@ -193,7 +189,7 @@ var aEvent string = `
var aBinding string = ` var aBinding string = `
{ {
"kind": "Binding", "kind": "Binding",
"apiVersion": "v1beta3", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "a"%s "name": "a"%s
}, },
...@@ -206,7 +202,7 @@ var aBinding string = ` ...@@ -206,7 +202,7 @@ var aBinding string = `
var aEndpoints string = ` var aEndpoints string = `
{ {
"kind": "Endpoints", "kind": "Endpoints",
"apiVersion": "v1beta3", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "a"%s "name": "a"%s
}, },
...@@ -214,7 +210,7 @@ var aEndpoints string = ` ...@@ -214,7 +210,7 @@ var aEndpoints string = `
{ {
"addresses": [ "addresses": [
{ {
"IP": "10.10.1.1" "ip": "10.10.1.1"
} }
], ],
"ports": [ "ports": [
...@@ -231,7 +227,7 @@ var aEndpoints string = ` ...@@ -231,7 +227,7 @@ var aEndpoints string = `
var deleteNow string = ` var deleteNow string = `
{ {
"kind": "DeleteOptions", "kind": "DeleteOptions",
"apiVersion": "v1beta3", "apiVersion": "v1",
"gracePeriodSeconds": null%s "gracePeriodSeconds": null%s
} }
` `
...@@ -462,17 +458,6 @@ func parseResourceVersion(response []byte) (string, float64, error) { ...@@ -462,17 +458,6 @@ func parseResourceVersion(response []byte) (string, float64, error) {
if err != nil { if err != nil {
return "", 0, fmt.Errorf("unexpected error unmarshaling resultBody: %v", err) 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{}) metadata, ok := resultBodyMap["metadata"].(map[string]interface{})
if !ok { if !ok {
return "", 0, fmt.Errorf("unexpected error, metadata not found in JSON response: %v", string(response)) 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 ...@@ -492,19 +477,6 @@ func parseV1Beta3ResourceVersion(resultBodyMap map[string]interface{}, response
return id, resourceVersion, nil 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 { func getPreviousResourceVersionKey(url, id string) string {
baseUrl := strings.Split(url, "?")[0] baseUrl := strings.Split(url, "?")[0]
key := baseUrl key := baseUrl
......
{ {
"kind": "ReplicationController", "kind": "ReplicationController",
"apiVersion": "v1beta3", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "test-controller", "name": "test-controller",
"namespace": "test", "namespace": "test",
......
...@@ -97,7 +97,7 @@ func NewMasterComponents(c *Config) *MasterComponents { ...@@ -97,7 +97,7 @@ func NewMasterComponents(c *Config) *MasterComponents {
if c.DeleteEtcdKeys { if c.DeleteEtcdKeys {
DeleteAllEtcdKeys() 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{}) rcStopCh := make(chan struct{})
controllerManager := controller.NewReplicationManager(restClient, c.Burst) controllerManager := controller.NewReplicationManager(restClient, c.Burst)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment