-
Notifications
You must be signed in to change notification settings - Fork 445
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
Conversation
There was a problem hiding this 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.
src/Azure.Functions.Cli/Actions/DeployActions/Platforms/KnativePlatform.cs
Outdated
Show resolved
Hide resolved
|
||
var host = GetFunctionHost(name, nameSpace); | ||
|
||
ColoredConsole.WriteLine(""); |
There was a problem hiding this comment.
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 ""
ColoredConsole.WriteLine(""); | |
ColoredConsole.WriteLine(); |
File.Delete("deployment.json"); | ||
|
||
var externalIP = await GetIstioClusterIngressIP(); | ||
if (externalIP == "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
@ahmelsayed all yours |
/cc @anirudhgarg for FYI |
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.