Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added knative support #967

Merged
merged 7 commits into from
Jan 11, 2019
Merged

Added knative support #967

merged 7 commits into from
Jan 11, 2019

Conversation

yaron2
Copy link
Contributor

@yaron2 yaron2 commented Jan 9, 2019

This PR adds knative as a target platform to the 'func deploy' command.

Non-HTTP trigger workloads are supported - the minScale annotation is added to non-HTTP trigger functions in order to avoid scale-to-zero.

Copy link
Contributor

@ahmelsayed ahmelsayed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few nitpicky comment here and there.

but the mainly I'm a bit confused about the usage of name and functionName in the KnativePlatform. I mentioned it more in the comment above below.


var host = GetFunctionHost(name, nameSpace);

ColoredConsole.WriteLine("");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you don't need the ""

Suggested change
ColoredConsole.WriteLine("");
ColoredConsole.WriteLine();

File.Delete("deployment.json");

var externalIP = await GetIstioClusterIngressIP();
if (externalIP == "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (externalIP == "")
if (string.IsNullOrEmpty(externalIP))

@@ -110,7 +110,7 @@ public override async Task RunAsync()
await DockerHelpers.DockerBuild(image, Environment.CurrentDirectory);

ColoredConsole.WriteLine("Pushing function image to registry...");
await DockerHelpers.DockerPush(image);
// await DockerHelpers.DockerPush(image);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this intentional? I don't see the image being pushed anywhere else

ColoredConsole.WriteLine("Plese note: it may take a few minutes for the knative service to be reachable");
}

private string GetFunctionHost(string functionName, string nameSpace) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: put the { on a new line.

knativeService.spec.runLatest.configuration.revisionTemplate.metadata.annotations.Add("autoscaling.knative.dev/minScale", min.ToString());
}

if (max > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: put the { on a new line.

knativeService.spec.runLatest.configuration.revisionTemplate.metadata.annotations = new Dictionary<string, string>();

// opt out of knative scale-to-zero for non-http triggers
if (!isHTTP) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: put the { on a new line.

{
var str = File.ReadAllText(string.Format("{0}/function.json", functionName));
var jObj = JsonConvert.DeserializeObject<FunctionJson>(str);
return jObj.bindings.Any(d=> d.type == "http");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you want httpTrigger, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking at the out binding, you're correct the in binding is what should be looked at

client = KubeApiClient.Create(options);
}

private async Task Deploy(string name, string image, string nameSpace, int min, int max)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit unclear about the use of this name here vs in the KubernetesPlatform.cs. In KubernetesPlatform it seems that name is used to name the deployment, while here, that name is used in the IsHttpTrigger method to check if that one function is in fact http, as well as used as a name for the deployment.

Shouldn't the check for IsHttpTrigger really be IsAnyHttpTrigger and then there enumerate all */function.json

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deploy command deploys a single function, thus a single function.json

}

private string GetFunctionHost(string functionName, string nameSpace) {
return string.Format("{0}.{1}.example.com", functionName, nameSpace);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the example.com part a placeholder or would people deploying to knative understand what to replace that with?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a fixed value in knative and can be expected.

@yaron2
Copy link
Contributor Author

yaron2 commented Jan 10, 2019

@ahmelsayed all yours

@ahmelsayed
Copy link
Contributor

/cc @anirudhgarg for FYI

@ahmelsayed ahmelsayed merged commit 189d59e into Azure:master Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants